//--------------------------------------------------------------------------- void FileListCreator(AnsiString TopDir, TStringList *SL, AnsiString Exts, bool SubFolder) { void *Handle; TWin32FindData Data; Exts = UpperCase(Exts); Handle = FindFirstFile((TopDir + "\\*.*").c_str(), &Data); if (Handle == INVALID_HANDLE_VALUE) return; if (!((AnsiString(Data.cFileName) == ".") || (AnsiString(Data.cFileName) == ".."))){ if (Exts.Pos(ExtractFileExt(Data.cFileName).UpperCase())){ SL->Add(TopDir + "\\" + Data.cFileName); } if ((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && SubFolder){ FileListCreator(TopDir + "\\" + Data.cFileName, SL, Exts); } } while (FindNextFile(Handle, &Data)){ if (!((AnsiString(Data.cFileName) == ".") || (AnsiString(Data.cFileName) == ".."))){ if (Exts.Pos(ExtractFileExt(Data.cFileName).UpperCase())){ SL->Add(TopDir + "\\" + Data.cFileName); } if ((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && SubFolder){ FileListCreator(TopDir + "\\" + Data.cFileName, SL, Exts); } } } FindClose(Handle); }
// это таймер приема данных void __fastcall TForm1::Timer1Timer(TObject *Sender) { char ch; DWORD temp; if (!ReadFile(hPort, &ch, 1, &temp, NULL)) return; // читаем посимвольно if (ch!='\r') sRecString+=ch; // и ждем конца строки else { int index =sRecString.Pos("Card Out"); // пришло сообщение о извлечении карты if (index!=0) // ну может имеет смысл это убрать все это. чтоб стабилнее работало { mLog->Lines->Add("get Card Out"); CurCardLost(); } index = sRecString.Pos("CurCard"); // CurCard - это префикс такой if (index==0) { sRecString=""; return; } AnsiString sNewCardID; sNewCardID=sRecString.SubString(index+8,sRecString.Length()-index-7); sRecString=""; if (sNewCardID!=lCurCardID->Caption) NewCardFound(sNewCardID); bGetCardFlag=true; } }
//--------------------------------------------------------------------------- /// 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; }
ConnectDialog::ConnectDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConnectDialog) { ui->setupUi(this); setWindowIcon(QIcon(QString::fromUtf8(":/resources/conceptclienticon.png"))); ui->label->setBuddy(ui->addressEdit); QStringList wordList; AnsiString history; #ifdef _WIN32 h_path = getenv("LOCALAPPDATA"); if (!h_path.Length()) h_path = getenv("APPDATA"); mkdir(h_path + "/ConceptClient-private"); h_path += (char *)"/ConceptClient-history.dat"; #else h_path = getenv("HOME"); mkdir(h_path + "/.ConceptClient-private", 0777L); h_path += (char *)"/.ConceptClient-history"; #endif history.LoadFile(h_path.c_str()); this->history = history; AnsiString sep = "\n"; int len_sep = sep.Length(); int pos = history.Pos(sep); int index = 0; int start = 0; while (pos > 0) { if (pos > 1) { history.c_str()[pos - 1] = 0; wordList << history.c_str(); } AnsiString temp = history; history = temp.c_str() + pos + len_sep - 1; pos = history.Pos(sep); } QCompleter *completer = new QCompleter(wordList); completer->setCaseSensitivity(Qt::CaseInsensitive); ui->addressEdit->setCompleter(completer); ui->addressEdit->setText(QString::fromUtf8("concept://")); ui->addressEdit->addAction(QIcon(QString::fromUtf8(":/resources/gtk-index.png")), QLineEdit::LeadingPosition); QAction *action = ui->addressEdit->addAction(QIcon(QString::fromUtf8(":/resources/gtk-delete.png")), QLineEdit::TrailingPosition); QStyle *l_style = QApplication::style(); ui->OkButton->setIcon(l_style->standardIcon(QStyle::SP_DialogOkButton)); ui->CancelButton->setIcon(l_style->standardIcon(QStyle::SP_DialogCancelButton)); QObject::connect(action, SIGNAL(triggered()), this, SLOT(clearHistory())); }
//--------------------------------------------------------------------------- AnsiString GetStrWithReplacedPoints(AnsiString Str, AnsiString PointStr=GetPointStr()) { AnsiString RetStr; int posPoint=Str.Pos(","); if (posPoint>0) RetStr=Str.SubString(1,posPoint-1)+PointStr+Str.SubString(posPoint+1,Str.Length()-posPoint); posPoint=Str.Pos("."); if (posPoint>0) RetStr=Str.SubString(1,posPoint-1)+PointStr+Str.SubString(posPoint+1,Str.Length()-posPoint); return RetStr; }
//--------------------------------------------------------------------------- bool IsFileNameOrURL(AnsiString S) { if (S.Pos(":\\")){ //ファイル(ルートフォルダのあるもの) return true; }else if (S.Pos("\\\\")){ //ネットワーク上のファイル? return true; }else if (S.Pos("://")){ //URL return true; } return false; }
void __fastcall TfrmMain::tcpServerExecute(TIdPeerThread *AThread) { TSimpleClient *Client; AnsiString Com; // System command AnsiString Msg; //Get the text sent from the client try { Msg = AThread->Connection->ReadLn("",5000); } catch (...) { } // Get the clients package info if (Msg.Length()==0)return; Client = (TSimpleClient *)(AThread->Data); // Check to see if the clients name has been assigned yet if (Client->Name == "Logging In") { // if not, assign the name and announce the client Client->Name = Msg; UpdateClientList(); BroadcastMessage("System", Msg + " has just logged in."); AThread->Connection->WriteLn(memEntry->Lines->Text); } else // If name is set, then send the message if (Msg[1] != '@') { // Not a system command BroadcastMessage(Client->Name, Msg); } else { // System command Com = UpperCase(Trim(Msg.SubString(2, Msg.Pos(":") -2))); Msg = UpperCase(Trim(Msg.SubString(Msg.Pos(":") +1, Msg.Length()))); if (Com == "CLIENTS") AThread->Connection->WriteLn( AnsiString("@") + AnsiString("clients:") + lbClients->Items->CommaText); if (Com == "KILL") KillClient(Msg); } }
//--------------------------------------------------------------------------- /// 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; }
AnsiString GenericUtils::ConvertPathCygwinToWindows(AnsiString original){ //In case of source path I have to fix the Drive letter as well if(original.Length() > 11 && original.Pos("/cygdrive/") == 1){ AnsiString driveLetter = original[11]; original = driveLetter + ":\\" + original.SubString(13, original.Length()); } AnsiString answer; //This loop fixes the spaces for(int i = 1; i <= original.Length(); i++){ if(i != original.Length() && original[i] == '\\' && original[i + 1] == ' '){ answer += ' '; i++; //Skip the next character since it is a space }else{ answer += original[i]; } } //Now fix the back slashes for(int i = 1; i <= answer.Length(); i++){ if(answer[i] == '/'){ answer[i] = '\\'; } } return answer; }
//--------------------------------------------------------------------------- void __fastcall TfrmClimateAM::FormShow(TObject *Sender) { int cant=AnsiString(condTemp->FileName).Length(); if (cant==0) { } else { int existe=access(condTemp->FileName, 0); if(existe==-1) // el archivo no existe { Application->MessageBox("The specified file does not exist!!!","¡Advertencia!",MB_OK); return; } else { FileData *util=new FileData(); AnsiString nombre = AnsiString(condTemp->FileName); int posicion=nombre.Pos("."); int longitud=nombre.Length(); int caract=longitud-posicion; AnsiString ext=nombre.SubString(posicion+1,caract); if(ext=="prn") num=util->GetFieldsName(List,condTemp->FileName); if(ext=="csv") num=util->GetFieldsNameFromCSVFile(List,condTemp->FileName); delete util; } } PutValuesOnForm(); }
//--------------------------------------------------------------------------- /// 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(); }
int __fastcall TThreadSubmitToDB::GetRowsForSQLLDR(const AnsiString & Text) { int Result = -1; if(Text.Pos(SQLLDR_KEY_WORD1) > 0) { Result = StrToIntEx(Text.SubString(strlen(SQLLDR_KEY_WORD1) + 1,Text.Length() - strlen(SQLLDR_KEY_WORD1) + 1).c_str()); } return Result; }
//--------------------------------------------------------------------------- TStringList * __fastcall TForm1::Parse(AnsiString str ,AnsiString delimeter) { TStringList *list = new TStringList ; int pos = str.Pos(delimeter); if(pos<=0) { list->Add(str);//no delimeter so only this return list ; } while(pos >0) { AnsiString unit = str.SubString(1,pos-1); str = str.SubString(pos+1,str.Length()-pos); list->Add(unit); pos = str.Pos(delimeter); } return list ; }
void __fastcall TfrmPropVisor::KeyPressDbl(TObject *Sender, char &Key) { AnsiString s; s = ((TEdit*)Sender)->Text; bool Num = ((Key >= '0') && (Key <= '9')); bool Dec = ((Key == DecimalSeparator) && (s.Pos(DecimalSeparator) == 0)); //bool Neg = ((Key == '-') && (((TEdit*)Sender)->SelStart == 0) && (s.Pos('-') == 0)); if( !Num && !Dec /*&& !Neg*/ ) Key = 0; }
//用空格或者'-'分割字符串,取后部分。 AnsiString GetStrName(AnsiString AStr) { AnsiString IName; int IPos; IPos = AStr.Pos("-"); if(IPos == 0) { IPos = AStr.Pos(" "); if(IPos == 0) { IName = ""; } else { IName = AStr.SubString(IPos + 1, AStr.Length()); } } else { IName = AStr.SubString(IPos + 1,AStr.Length()); } return IName; }
void TMainForm::setAddressFile(AnsiString filename) { AddressFile = filename; AnsiString caption = ExtractFileName(filename); int dotIndex = caption.Pos("."); if (0 != dotIndex) { caption = caption.SubString(1, dotIndex - 1); } MainForm->Caption = caption; addr_place = 1; addressFromFile->Checked = true; AbstractBase::resetAddressMap(); closeAllForms(); }
//用空格或者'-'分割字符串,取前部分。 AnsiString GetStrNo(AnsiString AStr) { AnsiString INo; int IPos; IPos = AStr.Pos("-"); if(IPos == 0) { IPos = AStr.Pos(" "); if(IPos == 0) { INo = ""; } else { INo = AStr.SubString(1, IPos - 1); } } else { INo=AStr.SubString(1, IPos - 1); } return INo; }
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]); }
//--------------------------------------------------------------------------- AnsiString __fastcall TRawPrint::TiraAcento(char C) { const AnsiString ComAcento = "çãáàâêéîíõóôúûÇÃÁÀÂÊÉÍÎÕÓÔÛÚº"; const AnsiString SemAcento = "caaaaeeiiooouuCAAAAEEIIOOOUUo"; const AnsiString Acento = ",~' ^^'^'~'^'^,~' ^^''^~'^^' "; int P = ComAcento.Pos(C); AnsiString Retorno; if(P != 0)//Quando encontrado Caracter com Acento, imprime o Caracter, volta o Carro e imprime o Caracter Especial Retorno = ((String)SemAcento[P] + (String)char(8) + (String)Acento[P]); else Retorno = C; return(Retorno); };
bool TDataSwitch::IsValid_HexStr(AnsiString strHex) { if (strHex.Length() != 12) return false; AnsiString strValid = "0123456789ABCDEF"; // 有效指令字符集 for (int i = 1; i <= strHex.Length(); i++) // index of AnsiString starts from 1 { if (strValid.Pos(strHex[i]) == 0) // input data verification { return false; } } return true; }
//--------------------------------------------------------------------------- // Split a NBD connection string (host:port) into the host and port parts. // bool __fastcall SplitConnectionString(AnsiString ConnectionString, AnsiString &HostPart, int &PortPart) { AnsiString sHost; int nPort = 0, nPortPos; nPortPos = ConnectionString.Pos(":") + 1; if (nPortPos) { sHost = ConnectionString.SubString(1,nPortPos - 2); if (TryStrToInt(ConnectionString.SubString(nPortPos, ConnectionString.Length() - nPortPos + 1), nPort) && nPort > 0 && nPort < 65536) { HostPart = sHost; PortPart = nPort; return true; } // if (port number is valid) } // if (nPortPos) return false; } // bool __fastcall SplitConnectionString(AnsiString ConnectionString, AnsiString &HostPart, int &PortPart)
void __fastcall TFrmCustomBill::GetMaster() { if (FMasterSql !="") { AnsiString sql = FMasterSql ; if (FWhereValue.Trim() != "") { if (sql.Pos("where") <=0) sql = sql + " where " +FWhereValue; else sql = sql + " and (" +FWhereValue +")"; } if (!dmMain->ExecSQL(FMasterSql, true, Cdsmaster)) RaiseErr("读取数据失败"); } }
//--------------------------------------------------------------------------- AnsiString ProvirkaFunc(AnsiString t,int &g) { g=t.Pos("("); AnsiString func=t.SubString(1,g-1),rez; if(g==1) rez="()"; if(func=="sqrt") rez="sqrt"; if(func=="sin") rez="sin"; if(func=="cos") rez="cos"; if(func=="tg") rez="tg"; if(func=="ln") rez="ln"; if(func=="exp") rez="exp"; if(func=="lg") rez="lg"; if(func=="abs") rez="abs"; if(func=="arcsin") rez="arcsin"; if(func=="arccos") rez="arccos"; if(func=="arctg") rez="arctg"; if(func=="ceil") rez="ceil"; if(func=="floor") rez="floor"; if(func=="sh") rez="sh"; if(func=="ch") rez="ch"; if(func=="th") rez="th"; if(func=="cth") rez="cth"; if(func=="sech") rez="sech"; if(func=="csch") rez="csch"; return rez; }
//--------------------------------------------------------------------------- bool TRsyncConfigAdapter::ParseNameValue(AnsiString input, AnsiString& name, AnsiString& value){ input = input.Trim(); if(input == "") return false; if(input[1] == '#') return false; int pos = input.Pos("="); if(pos == 0) return false; name = input.SubString(1, pos - 1).Trim(); value = input.SubString(pos + 1, input.Length()).Trim(); return true; }
//--------------------------------------------------------------------------- AnsiString __fastcall TDPAniver1::RetornaValorCampo( AnsiString Padrao) { AnsiString valor = "_FIM_"; short Pos = Padrao.Pos( "_" ); if(Pos) { AnsiString Id = Padrao.SubString( 1, Pos - 1 ); if(Id == "Emp") { try { Padrao = Padrao.SubString( 5, 100 ); valor = DSEmp->GT( Padrao ); } catch(...) { WDoc->Save(); WApp->Disconnect(); throw Exception("Não foi encontrado o padrão @" + Padrao + " na tabela dos dados.\n" + String("Verifique a lista de padrões que podem ser utilizados consultando a Ajuda.")); } } if(Id == "Ani") { try { Padrao = Padrao.SubString( 5, 100 ); valor = DSAniver2->GT( Padrao ); if(Padrao == "Data") valor = valor.SubString( 1, 5 ); } catch(...) { WDoc->Save(); WApp->Disconnect(); throw Exception("Não foi encontrado o padrão @" + Padrao + " na tabela dos dados.\n" + String("Verifique a lista de padrões que podem ser utilizados consultando a Ajuda.")); } } } return(valor); }
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); } } }
int __fastcall TItemList::GetSelected(LPCSTR pref, ListItemsVec& items, bool bOnlyObject) { for (TElTreeItem* item = tvItems->GetNextSelected(0); item; item = tvItems->GetNextSelected(item)){ ListItem* prop = (ListItem*)item->Tag; if (item->Hidden) continue; //. VERIFY (!item->Hidden); if (prop&&(!bOnlyObject||(bOnlyObject&&prop->m_Object))){ AnsiString key = *prop->key; if (pref){ if (1==key.Pos(pref)) items.push_back (prop); }else items.push_back (prop); } } return items.size(); }
//------------------------------------------------------------------------------ void ClimateFile::LoadClimateInformation() { AnsiString nombre = AnsiString(FileName); int posicion=nombre.Pos("."); int longitud=nombre.Length(); int caract=longitud-posicion; AnsiString ext=nombre.SubString(posicion+1,caract); if(ext=="prn") { RecNum=CountRegisters(FileName); GetColumnData(FileName , TitTMin , MinTemp ); GetColumnData(FileName , TitTMax , MaxTemp ); GetColumnData(FileName , TitPrec , Precipit ); GetColumnData(FileName , TitRad , Radiation); GetColumnData(FileName , TitET , ET); GetColumnData(FileName , TitIrri , Irri); GetColumnData(FileName , TitSoilTemp , SoilTemp); GetColumnData(FileName , TitSunshine , Sunshine); GetColumnData(FileName , TitDay , Day); GetColumnData(FileName , TitMonth , Month); GetColumnData(FileName , TitYear , Year); GetColumnData(FileName , TitObs , Obs); GetColumnData(FileName , TitObsCC , ObsCC); } if(ext=="csv") { RecNum=CountRegistersFromCSVFile(FileName); GetColumnDataFromCSVFile(FileName , TitTMin , MinTemp ); GetColumnDataFromCSVFile(FileName , TitTMax , MaxTemp ); GetColumnDataFromCSVFile(FileName , TitPrec , Precipit ); GetColumnDataFromCSVFile(FileName , TitRad , Radiation); GetColumnDataFromCSVFile(FileName , TitET , ET); GetColumnDataFromCSVFile(FileName , TitIrri , Irri); GetColumnDataFromCSVFile(FileName , TitSoilTemp , SoilTemp); GetColumnDataFromCSVFile(FileName , TitSunshine , Sunshine); GetColumnDataFromCSVFile(FileName , TitDay , Day); GetColumnDataFromCSVFile(FileName , TitMonth , Month); GetColumnDataFromCSVFile(FileName , TitYear , Year); GetColumnDataFromCSVFile(FileName , TitObs , Obs); GetColumnDataFromCSVFile(FileName , TitObsCC , ObsCC); } }
//--------------------------------------------------------------------------- /// 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; }
//=========================================================================== void __fastcall TfrmDeviceSetting::cbDeviceNameDropDown(TObject *Sender) { TStringList *DirList = new TStringList(); GetFolderList( ApplicationFolder+"\\.Gyro_Data", DirList ); cbDeviceName->Items->BeginUpdate(); cbDeviceName->Items->Clear(); for ( int i = 0; i < DirList->Count; i++) { AnsiString FolderName = DirList->Strings[i]; int GyroNamePosition = FolderName.Pos(".Gyro_Data\\") + strlen(".Gyro_Data\\"); AnsiString GyroName = FolderName.SubString(GyroNamePosition, FolderName.Length()); cbDeviceName->Items->Add(GyroName); } cbDeviceName->Items->EndUpdate(); if ( DirList != NULL ) delete DirList; }