//--------------------------------------------------------------------------- AnsiString __fastcall DirFromAbbr( AnsiString AbbrDir, AnsiString ProjDir ) // Получает имя директории из $(PRJ)\Obj (или типа того) { AbbrDir = ExcludeTrailingBackslash(AbbrDir); AnsiString Subs = AbbrDir.SubString( 1, 6); if (Subs == PrjDir) { AbbrDir.Delete(1,6); if (ProjDir == "") return ExtractFileDir(Project->NameOfFile) + AbbrDir; else return ProjDir + AbbrDir; } else if (Subs == MseDir) { char buff[301]; AbbrDir.Delete(1,6); if (GetMSEPathStr( pcProgram, buff, 300)) return buff + AbbrDir; return ExtractFileDir(Application->ExeName) + AbbrDir; } else if (Subs == DatDir) { char buff[301]; AbbrDir.Delete(1,6); if (GetMSEPathStr( pcData, buff, 300)) return buff + AbbrDir; return ExtractFileDir(Application->ExeName) + "\\Data" + AbbrDir; } else return AbbrDir; }
AnsiString __fastcall TMainFrm::ExcludeTrailingBackslash(AnsiString dir) { if ( *dir.AnsiLastChar() == '\\' ) dir.Delete(dir.Length(),1); return dir; }
bool __fastcall TEntryForm::InValidInteger(AnsiString label, TEditPlus *edit, int length) { if (edit->ReadOnly == true) return false; AnsiString ud = edit->Text; if (ud.IsEmpty() == true) { AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'." +" This is invalid for a non null integer field allowing" +" for "+length+" bytes of data"; Application->MessageBox(msg.c_str(), "No Data Entered", ID_OK); return true; } if (ud[1] == '-') ud.Delete(1,1); int n = ud.Length(); if (n <= length && strspn(ud.c_str(), "0123456789") == (unsigned)n) return false; AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'." +" This is invalid for a non null integer field allowing" +" for "+length+" bytes of data"; Application->MessageBox(msg.c_str(), "Invalid Number", ID_OK); return true; }
//--------------------------------------------------------------------------- /// Metoda odpowiada za znalezienie danych w przekazanym tekœcie, szukany tekst musi znajdowaæ siê pomiêdzy /// pocz¹tkowym znacznikiem a znakiem wystêpuj¹cym na koñcu tekstu, w przypadku nie znalezienie znacznika pocz¹tkowego /// metoda zwraca pusty tekst. AnsiString __fastcall ParsujDane::ZnajdzDane(AnsiString &AText, AnsiString AZnacznikPocz, char AZnakKonca) { int pozycjaZnacznik, start, koniec; AnsiString tekst, str = ""; pozycjaZnacznik = AText.Pos(AZnacznikPocz); start = pozycjaZnacznik; if (pozycjaZnacznik == 0) return ""; pozycjaZnacznik = pozycjaZnacznik + AZnacznikPocz.Length(); while(AText[pozycjaZnacznik] != AZnakKonca) { str += AText[pozycjaZnacznik]; pozycjaZnacznik++; if ((AText[pozycjaZnacznik] == ']' && AText[pozycjaZnacznik - 1] != '\"') || (AText[pozycjaZnacznik] == '\"' && AText[pozycjaZnacznik - 1] == '\\')) { str += AText[pozycjaZnacznik]; pozycjaZnacznik++; } } koniec = pozycjaZnacznik; AText.Delete(start, koniec + 1 - start); str.TrimLeft(); str.TrimRight(); return str; }
//--------------------------------------------------------------------------- /// Meotoda odpowiada za w³aœciwe wyszukiwanie danych opini, metoda przyjmuje znaczniki pocz¹tkowe oraz koñcowe, /// pomiêdzy którymi znajduj¹ siê po¿¹dane teksty. AnsiString __fastcall ParsujDane::ZnajdzTekstOpini(AnsiString &ATextOpini, AnsiString AZnacznikPocz, AnsiString AZnacznikKoniec, bool ATnij) { AnsiString txt; int pozycjaZnacznik, start, koniec; pozycjaZnacznik = ATextOpini.Pos(AZnacznikPocz); if (pozycjaZnacznik == 0) return ""; while (true) { txt += ATextOpini[pozycjaZnacznik]; if (ATnij) { if (txt.Pos(AZnacznikPocz) > 0) { txt = txt.Delete(1, AZnacznikPocz.Length()); } } if (txt.Pos(AZnacznikKoniec) > 0) break; pozycjaZnacznik++; } if (!ATnij) { start = AZnacznikPocz.Length() + 1; koniec = txt.Length() - AZnacznikPocz.Length() - AZnacznikKoniec.Length(); } else { start = 1; koniec = txt.Length() - AZnacznikKoniec.Length(); } txt = txt.SubString(start, koniec); txt.TrimLeft(); txt.TrimRight(); return txt; }
LPCSTR _CopyVal(LPCSTR src, AnsiString& dst, char separator) { LPCSTR p; u32 n; p = strchr(src, separator); n = (p > 0) ? (p - src) : xr_strlen(src); dst = src; dst = dst.Delete(n + 1, dst.Length()); return dst.c_str(); }
//--------------------------------------------------------------------------- /// Metoda odpowiedzialna za dostosowanie wad i zalet do zapisu do bazy danych void __fastcall ParsujDane::DostosujWadyIZalety(AnsiString &AText) { int pozycjaZnacznik; AnsiString str, text, znakKonca; if (AText.IsEmpty()) return; znakKonca = "<ENDL>"; while (true) { pozycjaZnacznik = AText.Pos(znakKonca); if (pozycjaZnacznik > 0) AText.Delete(pozycjaZnacznik, znakKonca.Length()); if (pozycjaZnacznik == 0) break; text = AText.SubString(1, pozycjaZnacznik - 1); UsunZnacznik(text, ' '); str += text + "<ENDL>"; AText.Delete(1, pozycjaZnacznik); } AText = str; }
bool __fastcall TEntryForm::InValidDouble(AnsiString label, TEditPlus *edit) { AnsiString ud = edit->Text; if (ud[1] == '-') ud.Delete(1,1); if (strspn(ud.c_str(), "0123456789.") == (unsigned)ud.Length()) return false; AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'." +" This is invalid for a non null double field"; Application->MessageBox(msg.c_str(), "Invalid Double", ID_OK); return true; }
//--------------------------------------------------------------------------- long double Str2Float(AnsiString s) { for (int i = 1; i <= s.Length(); i++) if (s[i] < '0' || s[i] > '9') if (s[i] == '.' || s[i] == ',') s[i] = DecimalSeparator; else { s.Delete(i, 1); i--; } return s.Length() ? StrToFloat(s) : 0; }
void __fastcall TfrmTreeFrame::LoadSubItem(TTreeNode *TN,TMenuItem * MI) { if ((MI->Caption=="-") || (!((MI->Tag ==0) || (MI->Tag ==1))) || (!MI->Enabled)) return ; AnsiString temp =MI->Caption; temp.Delete(temp.Pos("&"),1); TN = Tree->Items->AddChildObject(TN,temp,MI); TN->ImageIndex =MI->Tag; TN->SelectedIndex = MI->Tag; // inc(CurMenuIndex); for (int i=0;i<MI->Count;i++) LoadSubItem(TN, MI->Items[i]); }
//--------------------------------------------------------------------------- /// Metoda odpowiedzialna za usunieciê przekazanych znaczników z przekazanego tekstu, /// metoda umo¿liwia umieszczenie znacznika konca lini w zamian za przyjmowany znacznik void __fastcall ParsujDane::UsunZnacznik(AnsiString &AText, AnsiString AZnacznik, bool AWstawENDL) { int pozycjaZnacznik, i; i = 0; while (true) { pozycjaZnacznik = AText.Pos(AZnacznik); if (AZnacznik == ' ') { if (AText.Pos(' ') > 1) break; } if (pozycjaZnacznik > 0) AText.Delete(pozycjaZnacznik, AZnacznik.Length()); if (pozycjaZnacznik > 0 && AWstawENDL) AText.Insert("<ENDL>",pozycjaZnacznik); if (pozycjaZnacznik == 0) break; } AText.TrimLeft(); AText.TrimRight(); }
void __fastcall TMailSndForm::BuildRcptList(void) { AnsiString Buf; int I; SmtpClient->RcptName->Clear(); Buf = ToEdit->Text; while (TRUE) { I = Buf.Pos(";"); if (I <= 0) { SmtpClient->RcptName->Add(Trim(Buf)); break; } else { SmtpClient->RcptName->Add(Trim(Buf.SubString(1, I - 1))); Buf.Delete(1, I); } } }
void __fastcall TMainForm::TabSheet3Show(TObject *Sender) { // Отображение информации TOraQuery * refQuery = new TOraQuery(this); try { AnsiString refQueryStr = "SELECT "; ValueListEditorFind->Strings->Clear(); for (unsigned int i=0; i < m_view_list.size(); i++) { ValueListEditorFind->InsertRow(m_view_list [i].full_name, "", true); if (!m_view_list [i].ref_name.IsEmpty()) { ValueListEditorFind->ItemProps [i]->EditStyle = esPickList; AnsiString field = m_view_list [i].ref_name; field.Delete(1, 4); refQuery->SQL->Text = refQueryStr + field + " FROM " + m_shema + "." + m_view_list [i].ref_name + " ORDER BY " + field; refQuery->Open(); refQuery->First(); while (!refQuery->Eof) { ValueListEditorFind->ItemProps [i]->PickList->Add (refQuery->Fields->FieldByName (field)->AsString); refQuery->Next(); } } } refQuery->Close(); } __finally { safe_delete (refQuery); //delete refQuery; } }
/* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TSCFormasCompactas::Button1Click(TObject *Sender) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ extern vector<bool> ocultarNANDNOR; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ NANDyNOR->StringGrid->ColCount = Tabla.NumColumnas(); NANDyNOR->ScrollBar1->Max = Tabla.NumColumnas(); // metemos las cadenas en el StringGrid Este tratamiento es las funciones y las "X" for(int j = 0; j < Tabla.NumColumnas(); j++) { /*~~~~~~*/ int i = 0; /*~~~~~~*/ NANDyNOR->StringGrid->Cells[j][0] = ""; NANDyNOR->StringGrid->Cells[j][1] = ""; while(StringGrid1->Cells[j][i] != "") { NANDyNOR->StringGrid->Cells[j][0] = NANDyNOR->StringGrid->Cells[j][0] + StringGrid1->Cells[j][i]; i = i + 1; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString temp = NANDyNOR->StringGrid->Cells[j][0]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ temp.Delete(temp.Length(), 1); NANDyNOR->StringGrid->Cells[j][0] = temp; NANDyNOR->StringGrid->Cells[j][2] = temp; i = 0; while(StringGrid2->Cells[j][i] != "") { NANDyNOR->StringGrid->Cells[j][1] = NANDyNOR->StringGrid->Cells[j][1] + StringGrid2->Cells[j][i]; i = i + 1; } temp = NANDyNOR->StringGrid->Cells[j][1]; temp.Delete(temp.Length(), 1); NANDyNOR->StringGrid->Cells[j][1] = temp; NANDyNOR->StringGrid->Cells[j][3] = temp; } ocultarNANDNOR.clear(); /*~~~~~~~~~~~~~*/ AnsiString temp; /*~~~~~~~~~~~~~*/ if(Disyuntivo->Checked == true) { // POS for(int j = 0; j < Tabla.NumColumnas(); j++) { temp = NANDyNOR->StringGrid->Cells[j][0]; if(Trim(temp).AnsiPos("*")) ocultarNANDNOR.push_back(false); else ocultarNANDNOR.push_back(true); if(Trim(NANDyNOR->StringGrid->Cells[j][0]) != "") { // Estas llamadas son para NOR - funciones temp = NANDyNOR->StringGrid->Cells[j][0]; temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, true); temp.Insert("~(", 1); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][2] = temp; // Hacemos el cambio a Expresion NAND - funciones temp = NANDyNOR->StringGrid->Cells[j][0]; temp = InvertirVariables(temp); temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, false); temp.Insert("~(~(", 1); temp.Insert(")", temp.Length()); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][0] = temp; // Ahora hay que escribirlo en su formulario } else { NANDyNOR->StringGrid->Cells[j][0] = ""; } temp = NANDyNOR->StringGrid->Cells[j][1]; if(Trim(NANDyNOR->StringGrid->Cells[j][1]) != "") { // Estas llamadas son para NOR - "X" temp = NANDyNOR->StringGrid->Cells[j][1]; temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, true); temp.Insert("~(", 1); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][3] = temp; // // Ahora hay que escribirlo en su formulario // Hacemos el cambio a Espresion NAND - "X" // temp = NANDyNOR->StringGrid->Cells[j][1]; temp = InvertirVariables(temp); temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, false); temp.Insert("~(~(", 1); temp.Insert(")", temp.Length()); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][1] = temp; } else { NANDyNOR->StringGrid->Cells[j][1] = ""; } } } else // Ahora hacemos tratamiento de la expresion SOP { for(int j = 0; j < Tabla.NumColumnas(); j++) { temp = NANDyNOR->StringGrid->Cells[j][0]; if(Trim(temp).AnsiPos("+")) ocultarNANDNOR.push_back(false); else ocultarNANDNOR.push_back(true); if(Trim(NANDyNOR->StringGrid->Cells[j][0]) != "") { // Estas llamadas son para NOR - funciones temp = NANDyNOR->StringGrid->Cells[j][0]; temp = InvertirVariables(temp); temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, false); temp.Insert("~(~(", 1); temp.Insert(")", temp.Length()); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][2] = temp; // // Ahora hay que escribirlo en su formulario // Hacemos el cambio a Espresion NAND - funciones // temp = NANDyNOR->StringGrid->Cells[j][0]; temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, true); temp.Insert("~(", 1); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][0] = temp; // Ahora hay que escribirlo en su formulario } else { NANDyNOR->StringGrid->Cells[j][0] = ""; } temp = NANDyNOR->StringGrid->Cells[j][1]; if(Trim(NANDyNOR->StringGrid->Cells[j][1]) != "") { // Estas llamadas son para NOR - "X" temp = NANDyNOR->StringGrid->Cells[j][1]; temp = InvertirVariables(temp); temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, false); temp.Insert("~(~(", 1); temp.Insert(")", temp.Length()); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][3] = temp; // Hacemos el cambio a Espresion NAND - "X" temp = NANDyNOR->StringGrid->Cells[j][1]; temp = InvertirExpresiones(temp); temp = CambiarSignos(temp, true); temp.Insert("~(", 1); temp.Insert(")", temp.Length()); NANDyNOR->StringGrid->Cells[j][1] = temp; } else { NANDyNOR->StringGrid->Cells[j][1] = ""; } } } for(int j = 0; j < Tabla.NumColumnas(); j++) { NANDyNOR->StringGrid->Cells[j][0] = NombresCompletos(NANDyNOR->StringGrid->Cells[j][0]); NANDyNOR->StringGrid->Cells[j][2] = NombresCompletos(NANDyNOR->StringGrid->Cells[j][2]); NANDyNOR->StringGrid->Cells[j][1] = NombresCompletos(NANDyNOR->StringGrid->Cells[j][1]); NANDyNOR->StringGrid->Cells[j][3] = NombresCompletos(NANDyNOR->StringGrid->Cells[j][3]); } NANDyNOR->Exp->Checked = false; NANDyNOR->ShowModal(); // SCFormasCompactas->Hide(); }
void TForm1::AnalyseOneFunction(int &FunctionCount, int NumberOfCalls, AnsiString FunctionString, std::ofstream &OutFile) { AnsiString Prelim = "./"; for(int x=0;x<5000;x++) { DupNumArray[x] = -1; MissingNumArray[x] = -1; } Label1->Caption = "Analysing function: " + FunctionString + " (" + AnsiString(FunctionCount + 1) + "/" + AnsiString(NumberOfCalls) + ")"; Form1->Repaint(); int DupNumArrayIndex = 0; for(int x=0;x<NumFiles;x++) { AnsiString FullFileName = Prelim + FileString[x]; std::ifstream InFile(FullFileName.c_str()); if(InFile == 0) { ShowMessage("Input file failed to open - " + FileString[x]); return; } char Buffer[5000]; bool EndOfFile = false; while(!EndOfFile) { InFile.getline(Buffer, 5000); AnsiString OneLine(Buffer); for(int x = 1; x< OneLine.Length() - FunctionString.Length() + 1;x++) { if(OneLine.SubString(x,FunctionString.Length() + 1) == FunctionString + '(') //rule out other functions that contain the sought function name (allow to be preceded by space, !, ., > or ( {if((x == 1) || (OneLine[x-1] < '"') || (OneLine[x-1] == '.') || (OneLine[x-1] == '>') || (OneLine[x-1] == '(')) { AnsiString NumberLineStr = OneLine.SubString(x + FunctionString.Length() + 1,OneLine.Length() - (x + FunctionString.Length() + 1)); AnsiString NumberString = ""; while((NumberLineStr.Length() > 0) && ((NumberLineStr[1] <= '9') && (NumberLineStr[1] >= '0'))) { NumberString+= NumberLineStr[1]; NumberLineStr.Delete(1,1); } if(NumberString != "") { int Number = NumberString.ToInt(); DupNumArray[DupNumArrayIndex] = Number; DupNumArrayIndex++; } } } } if(InFile.eof()) { EndOfFile = true; } } InFile.close(); } //Label1->Caption = "Array analysis started for function " + FunctionString; //Form1->Repaint(); int MaxIndex = -1;//so first brings it to 0 int MaxNumber = -1; for(int x=0;x<5000;x++) { if(DupNumArray[x] > -1) { MaxIndex++; if(DupNumArray[x] > MaxNumber) MaxNumber = DupNumArray[x]; } else break; } for(int x=0;x<MaxIndex+1;x++) { MissingNumArray[x] = DupNumArray[x]; } //check for duplicates for(int x=0;x<MaxIndex + 1;x++) { int CheckNumber = DupNumArray[x]; if(CheckNumber == -1) continue; int RepeatCount = 0; for(int y=x+1;y<MaxIndex + 1;y++) { if(DupNumArray[y] == CheckNumber) { RepeatCount++; DupNumArray[y] = -1;//so it isn't counted again if appears more than twice in all } } if(RepeatCount > 0) { AnsiString MessageString = "Number " + AnsiString(CheckNumber) + " repeated " + AnsiString(RepeatCount) + " times in function " + FunctionString; if(Screen) { int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL); if (button == IDCANCEL) { BreakFlag = true; return; } } if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10); } } //now check for missing numbers if(CheckBox1->Checked) { int IncNumber = 0; bool FoundFlag=false; while(IncNumber <= MaxNumber) { FoundFlag = false; for(int x=0;x<MaxIndex + 1;x++) { if(MissingNumArray[x] == IncNumber) { FoundFlag = true; break; } } if(!FoundFlag) { AnsiString MessageString = "Number " + AnsiString(IncNumber) + " missing for function " + FunctionString; if(Screen) { int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL); if (button == IDCANCEL) { BreakFlag = true; return; } } if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10); } IncNumber++; } } FunctionCount++; }
//--------------------------------------------------------------------------- void __fastcall TBolBB::SetCampoLivre(AnsiString CampoLivre) { NossoNumero = ""; CodigoDeBarra = CodigoBanco + CodigoMoeda; int Dias = CalculaDatas( DataVencimento, 19971007, DIFDATAS_DIAS ) - 1; CodigoDeBarra = CodigoDeBarra + IntToStr( 0 ).sprintf( "%04d", Dias ); CodigoDeBarra = CodigoDeBarra + ValorBoleto; AnsiString FL = CampoLivre.SubString( 1, 25 ); // elimina o ultimo digito do campolivre AnsiString FLU = CampoLivre; // flu ... AnsiString Num = GetNumeroDocumento(); //---------------------------------------------------------------------------- // Percorre os caracteres do campo livre, procurando pela letra 'Z' // que devera ser substituida pelo nosso numero, que neste caso, sera o // proprio numero do documento, que é o mes, o ano, o codigo // e o tipo de faturamento do cliente, refenrentes a cobranca. //---------------------------------------------------------------------------- for( int a = FL.Length(); a >= 1; a-- ) { if( FL[a] == 'Z' ) // 'Z' indica local para nosso numero { if( Num.Length() ) // se houver numero de documento { FL[a] = ( char ) ( ( (Num[Num.Length()]) - 48 ) + 65 ); Num = Num.Delete( Num.Length(), 1 ); } else { FL[a] = 'A'; // caso o Num esteja vazio, troca o 'Z' pelo 'A' } } } //---------------------------------------------------------------------------- // Percorre os caracteres do campo livre, e se o caracter for maior ou igual // a 65 (Inicio das letras maiusculas), diminui de 65, gerando assim um indice // numerico para cada letra encontrada. //---------------------------------------------------------------------------- for( int a = 1; a <= FL.Length(); a++ ) { if( FL[a] >= 'A' ) { AnsiString Letra = ( char ) ( FL[a] ) - 65; CodigoDeBarra = CodigoDeBarra + Letra; NossoNumero = NossoNumero + Letra; } else { CodigoDeBarra = CodigoDeBarra + String( FL[a] ); } } LinhaDigitavel = CodigoDeBarra; //---------------------------------------------------------------------------- // Verifica se o ultimo caracter do campo livre (FLU) é igual a 1 e se for, // calcula o digito verificador utilizando o modulo 11 //---------------------------------------------------------------------------- if( FLU[FLU.Length()] == '1' ) { short D = StrToInt(CalcMod11( NossoNumero )); AnsiString Dig = ""; if( D < 10 ) { Dig = IntToStr( D ); } else { Dig = "X"; } NossoNumero = NossoNumero + "-" + Dig; } };
/* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TFormasNormales::BitBtn1Click(TObject *Sender) { /*~~~~~~~~~~*/ int error = 0; /*~~~~~~~~~~*/ // Quitamos todos los blancos for(int j = 0; j < StringGrid1->ColCount; j++) { /*~~~~~~~~~~~~~~~~~~~~*/ AnsiString cadena = ""; int k = 1; /*~~~~~~~~~~~~~~~~~~~~*/ while(k <= StringGrid1->Cells[j][0].Length()) { if(StringGrid1->Cells[j][0].SubString(k, 1) == " ") { cadena = StringGrid1->Cells[j][0]; cadena.Delete(k, 1); StringGrid1->Cells[j][0] = cadena; } else k = k + 1; } /*~~~~~~*/ int l = 1; /*~~~~~~*/ while(l <= StringGrid2->Cells[j][0].Length()) { if(StringGrid2->Cells[j][0].SubString(l, 1) == " ") { cadena = StringGrid2->Cells[j][0]; cadena.Delete(l, 1); StringGrid2->Cells[j][0] = cadena; } else l = l + 1; } } // // Comprobamos que los valores se encuentran entre los limites establecidos en la // función // for(int j = 0; j < StringGrid1->ColCount; j++) { StringGrid1->Cells[j][0] = StringGrid1->Cells[j][0].Trim(); /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString temp, temp2 = ""; /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ for(int i = 0; i < StringGrid1->Cells[j][0].Length(); i++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString car = StringGrid1->Cells[j][0].SubString(i + 1, 1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if((car < '0') | (car > '9')) { if(((car != ",") & (car != ":")) | (temp == "")) { error = 1; } else if(temp.ToInt() >= Tabla.NumFilas()) { error = 2; } else // si el valor es correcto se borra la var. temporal { if(car == ":") { if(temp2 != "") error = 3; else temp2 = temp; if(i == StringGrid1->Cells[j][0].Length() - 1) error = 3; } else { if((temp2 != "") & (temp2 > temp)) error = 4; temp2 = ""; } temp = ""; } } else { temp = temp + car; // si es el final no va a haber coma if(i == StringGrid1->Cells[j][0].Length() - 1) { if(temp.ToInt() >= Tabla.NumFilas()) error = 2; if((temp2 != "") & (temp2 > temp)) error = 4; } } if(error != 0) break; } if(error != 0) break; } // en las X for(int j = 0; j < StringGrid2->ColCount; j++) { StringGrid2->Cells[j][0] = StringGrid2->Cells[j][0].Trim(); /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString temp, temp2 = ""; /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ for(int i = 0; i < StringGrid2->Cells[j][0].Length(); i++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString car = StringGrid2->Cells[j][0].SubString(i + 1, 1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if((car < '0') | (car > '9')) { if(((car != ",") & (car != ":")) | (temp == "")) { error = 1; } else if(temp.ToInt() >= Tabla.NumFilas()) { error = 2; } else // si el valor es correcto se borra la var. temporal { if(car == ":") { if(temp2 != "") error = 3; else temp2 = temp; if(i == StringGrid1->Cells[j][0].Length() - 1) error = 3; } else { if((temp2 != "") & (temp2 > temp)) error = 4; temp2 = ""; } temp = ""; } } else { temp = temp + car; // si es el final no va a haber coma if(i == StringGrid2->Cells[j][0].Length() - 1) { if(temp.ToInt() >= Tabla.NumFilas()) error = 2; if((temp2 != "") & (temp2 > temp)) error = 4; } } if(error != 0) break; } if(error != 0) break; } if(error == 1) Application->MessageBox(MENSAJE(msgCaracterNoValido), NULL); if(error == 2) Application->MessageBox(MENSAJE(msgNoTantasVariables), NULL); if(error == 3) Application->MessageBox(MENSAJE(msgCaracterDosPuntos), NULL); if(error == 4) Application->MessageBox(MENSAJE(msgRangoErroneo), NULL); // si todo esta bien introducimos los valores en el objeto Tabla if(error == 0) { // inicializamos el objeto Tabla con ceros o unos for(int i = 0; i < Tabla.NumFilas(); i++) { for(int j = 0; j < Tabla.NumColumnas(); j++) { if(FormasNormales->Disyuntivo->Checked) Tabla.EscribirDinArray(i, j, '0'); else Tabla.EscribirDinArray(i, j, '1'); } } /* * introducimos los valores de cada funcion en el objeto Tabla comprobando que tan * solo se asigna un valor a cada posición y sacando una advertencia en caso * contrario, persistiendo la X sobre los unos o ceros */ for(int j = 0; j < StringGrid1->ColCount; j++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString temp, temp2 = ""; /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ for(int i = 0; i < StringGrid1->Cells[j][0].Length(); i++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString car = StringGrid1->Cells[j][0].SubString(i + 1, 1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if((car != ",") & (car != ":")) { temp = temp + car; // si es el final no va a haber coma if(i == StringGrid1->Cells[j][0].Length() - 1) { /*~~~~~*/ int k, l; /*~~~~~*/ if(temp2 == "") k = temp.ToInt(); else k = temp2.ToInt(); l = temp.ToInt(); for(; k <= l; k++) { if(FormasNormales->Disyuntivo->Checked) Tabla.EscribirDinArray(k, j, '1'); else Tabla.EscribirDinArray(k, j, '0'); } temp = ""; temp2 = ""; } } else if(car == ":") { temp2 = temp; temp = ""; } else { /*~~~~~*/ int k, l; /*~~~~~*/ if(temp2 == "") k = temp.ToInt(); else k = temp2.ToInt(); l = temp.ToInt(); for(; k <= l; k++) { if(FormasNormales->Disyuntivo->Checked) Tabla.EscribirDinArray(k, j, '1'); else Tabla.EscribirDinArray(k, j, '0'); } temp = ""; temp2 = ""; } } } // Aqui metemos las X for(int j = 0; j < StringGrid2->ColCount; j++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString temp, temp2 = ""; /*~~~~~~~~~~~~~~~~~~~~~~~~~*/ for(int i = 0; i < StringGrid2->Cells[j][0].Length(); i++) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString car = StringGrid2->Cells[j][0].SubString(i + 1, 1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if((car != ",") & (car != ":")) { temp = temp + car; // si es el final no va a haber coma if(i == StringGrid2->Cells[j][0].Length() - 1) { if ( ((FormasNormales->Disyuntivo->Checked) & (Tabla.LeerDinArray(temp.ToInt(), j) == '1')) | ( (FormasNormales->Conjuntivo->Checked) & (Tabla.LeerDinArray(temp.ToInt(), j) == '0') ) ) { Application->MessageBox(MENSAJE(msgSobreescribeConX), NULL); } /*~~~~~*/ int k, l; /*~~~~~*/ if(temp2 == "") k = temp.ToInt(); else k = temp2.ToInt(); l = temp.ToInt(); for(; k <= l; k++) { Tabla.EscribirDinArray(k, j, 'X'); } temp = ""; temp2 = ""; } } else if(car == ":") { temp2 = temp; temp = ""; } else { if ( ((FormasNormales->Disyuntivo->Checked) & (Tabla.LeerDinArray(temp.ToInt(), j) == 1)) | ((FormasNormales->Conjuntivo->Checked) & (Tabla.LeerDinArray(temp.ToInt(), j) == 0)) ) { Application->MessageBox(MENSAJE(msgSobreescribeConX), NULL); } /*~~~~~*/ int k, l; /*~~~~~*/ if(temp2 == "") k = temp.ToInt(); else k = temp2.ToInt(); l = temp.ToInt(); for(; k <= l; k++) { Tabla.EscribirDinArray(k, j, 'X'); } temp = ""; temp2 = ""; } } } Application->MessageBox(MENSAJE(msgSCGuardado), ""); } }