home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Shareware for Win 95
/
Chip-Shareware-Win95.bin
/
ostatni
/
delphi
/
delphi1
/
fldinfo.exe
/
FLDINFO.PAS
next >
Wrap
Pascal/Delphi Source File
|
1995-10-09
|
4KB
|
114 lines
unit FldInfo;
(*
Unit to save and recall DataSet field informaion to and and from an INI file
This is usefull if the user sizes the columns and rearrages them. This
allows a program to return their setting.
Author: William R. Florac
Company: FITCO, Verona, WI (wee little company from my house)
Copyright 1995, FITCO. All rights reserved.
1) Users of Fldinfo must accept this disclaimer of warranty:
"FldInfo is supplied as is. The author disclaims all
warranties, expressed or implied, including, without limitation,
the warranties of merchantability and of fitness for any purpose.
The author assumes no liability for damages, direct or conse-
quential, which may result from the use of FldInfo."
2) This Unit is donated to the public as public domain.
3) This Unit can be freely used and distributed in commercial and private
environments provided this notice is not modified in any way.
4) If you do find this Unit handy and you feel guilty
for using such a great product without paying someone,
please feel free to send a few bucks ($25) to support further
development.
5) This file was formated with tabs set to 2.
Please forward any comments or suggestions to Bill Florac at:
email: flash@etcconnect.com
www: http://www.etcconnect.com/fitco.html
mail: FITCO
209 Jenna Dr
Verona, WI 53593
Revision History
1.0 10-4-95 Initial release.
1.1 10-9-95 Changes procedures from TTable to TDataSet so
unit will work with queries too.
*)
interface
uses
inifiles, sysutils, dbTables, db;
procedure GetFieldInfo(IniFileName: TFileName; DS: TDataSet);
procedure PutFieldInfo(IniFileName: TFileName; DS: TDataSet);
implementation
procedure GetFieldInfo(IniFileName: TFileName; DS: TDataSet);
{gets a dataset field info from an ini file}
var
IniFile: TIniFile;
ColWidth: longint;
ColName: String;
IndexStr: String;
X: integer;
aField: TField;
IniString: string;
comma: integer;
begin
{create an ini object}
IniFile := TIniFile.Create(IniFileName);
{fields are save in the section <DataSetname>Fields and indexed by column
number, the field name and with is saved}
{select each field and reindex it}
for X := 0 to DS.FieldCount - 1 do begin
{create a string for the column number to find}
Str(X, IndexStr);
IniString := IniFile.ReadString(DS.Name+'Fields', IndexStr, '');
{find the comma, the width is to the right}
comma := pos(',',IniString);
if comma > 0 then begin {if we found one}
ColName := Copy(IniString, 1, comma -1);
ColWidth := StrToInt(Copy(IniString, comma + 1, 20));
if ColName <> '' then begin
aField := DS.FindField(ColName);
{make sure we found one}
if aField <> nil then begin
{now set the values}
aField.DisplayWidth := ColWidth;
aField.Index := X;
end;
end;
end;
end;
IniFile.Free; {let us not forget this!}
end; {of GetFieldInfo}
procedure PutFieldInfo(IniFileName: TFileName; DS: TDataSet);
{saves a DataSet field info to an ini file}
var
X: integer;
IndexStr: String;
IniFile: TIniFile;
begin
IniFile := TIniFile.Create(IniFileName);
{fields are save in the section <DataSetname>Fields and indexed by column
number, the field name and with is saved}
for X := 0 to DS.FieldCount - 1 do begin
{create a string out of the column number}
Str(X, IndexStr);
{save it...}
IniFile.WriteString(DS.Name+'Fields', IndexStr,
DS.Fields[x].FieldName + ',' + IntToStr(DS.Fields[x].DisplayWidth));
end;
IniFile.Free; {let us not forget this!}
end; {of PutFieldInfo}
end. {of unit}