You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
uses
IniFiles;
var
iniMem: TMemIniFile; // ini-File (ready only one time)
// Load the ini-information once - maybe at startup
function TMyForm.LoadIniFile:boolean;
var
SL : TStringList;
return : Boolean;
iniFile : String;
begin
iniFile:='myFormConfig.ini';
return:=true;
if not FileExists(ExtractFilePath(Application.Exename)+iniFile) then
begin
MessageDlg('ini-File not found!', mtError, [mbOK], 0);
return:=false;
end;
if not return then halt;
iniMem:=TMemIniFile.Create('');
SL:=TStringList.Create;
SL.LoadFromFile(ExtractFilePath(Application.Exename)+iniFile);
iniMem.SetStrings(SL);
LoadIniFile:=return;
end;
procedure TMyForm.DoThis;
begin
ShowMessage(iniMem.ReadString('Section','Attribute','Default-Value'));
end;
116
Delphi
Strings
String nach einem Teilstring durchsuchen
searchFor:='this';
text:='this is a simple text';
if pos(searchFor,text)>0 then
begin
ShowMessage('found');
end;
177
Delphi
Filehandling
Prüfen ob Datei existiert
procedure TForm1.CheckIfFileExists();
var
filePath : String;
begin
filePath:='C:\User\myUser\text.txt';
if FileExists(filePath) then
begin
ShowMessage('There it is! ;-)');
end
else
begin
ShowMessage('Whow, file is missing at this place :-(');
end;
end;
221
Delphi
Strings
Position eines Teilstrings finden
searchFor:='simple';
text:='this is a simple text';
ShowMessage(IntToStr(pos(searchFor,text)));
// 11
8
Caché
Datum, Zeit
Aktuelles Datum/Uhrzeit
; Datum und Uhrzeit formatiert ausgeben
Set datuhr=$ZDateTime($Horolog,8)
; ergibt 20100308 09:47:36
; nur Datum
Set dat=$ZDate($Horolog,3) ; = 2010-03-08
; nur Zeit
Set uhr=$ZTime($Piece($H,",",2)) ; = 09:50:20
12
Caché
Datenbank
Lesen Datensatzes
; Es existiert eine Tabelle namens Table.Cities welche einen Eintrag mit der ID=15 enthält. Diese Tabelle enthält das Feld "Name"
Set ds=##class(Table.Cities).%OpenId(15)
Write !,ds.Name
; Oder über SQL
Set result = ##class(%Library.ResultSet).%New()
Set sql = "SELECT Name FROM Table.Cities WHERE ID=15"
Do result.Prepare(sql)
Do result.Execute("")
For
{
Quit:'result.Next()
Set name=result.Data("Name")
}
17
Caché
HTTP Form Submit
GET Link-Parameter lesen
; http://localhost:1972/csp/test/page.csp?name=john
Set linkparm=$Get(%request.Data("name",1))
Write !,linkparm ; = john
18
Caché
Textdateien
Textdatei zeilenweise auslesen
Set stream=##class(%FileCharacterStream).%New()
Set stream.Filename="c:\myfile.txt"
While 'stream.AtEnd
{
Set line=stream.ReadLine()
; Process the line here
}