Delphi for Linux?
Tips:
procedure TForm1.Edit1Change(Sender: TObject); begin With Edit1 do if Text <> '' then Query1.Locate('code',Edit1.Text,[loPartialKey]); end;
To filter and sort a table in Delphi 1.0 you can use a QBE (Query by Example) file as the TableName TTable's property. This is useful to filter, sort or join tables, while still using the TTable component. QBE files can be created in Database Desktop.
To pack (remove phisically all deleted records) from a Paradox table you must use this code
procedure ParadoxPack(Table : TTable); var TBDesc : CRTblDesc; hDb: hDbiDb; TablePath: array[0..dbiMaxPathLen] of char; begin FillChar(TBDesc,Sizeof(TBDesc),0); with TBDesc do begin StrPCopy(szTblName,Table.TableName); StrPCopy(szTblType,szParadox); bPack := True; end; hDb := nil; Check(DbiGetDirectory(Table.DBHandle, True, TablePath)); Table.Close; Check(DbiOpenDatabase(nil, 'STANDARD', dbiReadWrite, dbiOpenExcl,nil,0, nil, nil, hDb)); Check(DbiSetDirectory(hDb, TablePath)); Check(DBIDoRestructure(hDb,1,@TBDesc,nil,nil,nil,False)); Table.Open; end; To pack Dbase tables use this command DBIPackTable(Table1.DBHandle,Table1.Handle,nil,nil,True);
procedure TMainForm.NewIni(const NomeIni: string); var F: System.Text; i: Byte; begin System.Assign(F, NomeIni); System.ReWrite(F); System.WriteLn(F, '[Campi_Ordine]'); for i:=1 to Table1.FieldCount do System.WriteLn(F, 'Campo',i,'=',Table1.Fields[i-1].FieldName); System.WriteLn(F, ''); System.WriteLn(F, '[Campi_Size]'); for i:=1 to Table1.FieldCount do System.WriteLn(F, 'Campo',i,'=',Table1.Fields[i-1].DisplayWidth); System.Close(F); end; procedure TMainForm.SaveIni(const FN: String); var Ini: TIniFile; i: Integer; begin NewIni(FN); Ini := TIniFile.Create(FN); with Ini do begin for i:=1 to Table1.FieldCount do begin S:= Table1.Fields[i-1].FieldName; WriteString('Campi_Ordine', 'Campo'+IntToStr(i), Table1.Fields[i-1].FieldName); WriteInteger('Campi_Size', 'Campo'+IntToStr(i), Table1.Fields[i-1].DisplayWidth); end; end; Ini.Free; end; procedure TMainForm.LoadIni(const FN: String); var Ini: TIniFile; i: Integer; j: Longint; S: String; function MyReadInteger(const Section, Ident: string): Longint; begin result := Ini.ReadInteger(Section, Ident, -1); if result=-1 then raise Exception.Create('Errore nel file di configurazione.'); end; function MyReadString(const Section, Ident: string): String; begin result := Ini.ReadString(Section, Ident, ''); if result='' then raise Exception.Create('Errore nel file di configurazione.'); end; begin Ini := TIniFile.Create(FN); try with Ini do begin for i:=1 to Table1.FieldCount do begin S:= MyReadString('Campi_Ordine', 'Campo'+IntToStr(i)); j:= MyReadInteger('Campi_Size', 'Campo'+IntToStr(i)); Table1.FieldByName(S).Index := i-1; Table1.FieldByName(S).DisplayWidth := j; end; end; finally Ini.Free; end; end;
unit IniStr; {Written by Ed Jordan} interface uses Classes; type TIniStringlist = class( TStringList ) public procedure LoadFromIni( const FileName, Section: string); procedure SaveToIni( const FileName, Section: string); end; implementation uses IniFiles, SysUtils; procedure TIniStringList.LoadFromIni( const FileName,Section: string); var Index: Integer; Line: string; begin with TIniFile.Create( FileName ) do try ReadSectionValues( Section, Self); for Index:= 0 to Count - 1 do begin { Remove the identifier name ...} Line:= Values[ IntToStr( Index ) ]; { Delete the tilde ... } System.Delete( Line, 1, 1); Strings[ Index ]:= Line; end; finally Free; end; end; procedure TIniStringList.SaveToIni( const FileName, Section: string); var Index: Integer; Line: string; begin with TIniFile.Create( FileName ) do try EraseSection( Section ); for Index:= 0 to Count - 1 do begin { Preserve leading white space, blank lines ...} Line:= '~' + Strings[ Index ]; WriteString( Section, IntToStr( Index ), Line); end; finally Free; end; end; end. Usage: var L: TIniStringList; begin L:= TIniStringList.Create; L.LoadFromIni('MyFile.Ini', 'Alati'); {process L..} L.Free; end
See also:
file: /Techref/language/delphis.htm, 5KB, , updated: 2013/7/23 10:21, local time: 2024/11/26 06:13,
18.224.65.198:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/techref/language/delphis.htm"> language delphis</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.