Each Action overrides create so that a default menu caption can be defined.
Custom OnRead Event
File_IO := TmcFile_IO.create(self);
File_IO.OnRead := OnReadExecute;
File_IO.Open(self) ; // Displays the File Open Dialog Box
// Called after a file is selected and opened as a read only text file
procedure TForm1.OnReadExecute(Sender: TObject; var F: Textfile);
var
S : string;
begin
while not eof(f) do begin
readln(f, s);
Memo1.Lines.Add(S);
end;
end;
This was written as a generic File I/O interface that could be
accessed via Actions.
This component will be the basis of
An ini file processor
An xml file processor
by overloading only FileOpen and FileSave. The rest of the code
should be common.
Other applications will use OnRead and OnWrite
The labortory will process data buffers
Increased Depth of field will use OnRead to call FileOpen
for multiple images - goldxx.jpg where xx is 01 to xx
INI File Processing
TMemIniFile does not preserve blank lines or comments (lines which start with ";"). It seems ok for reading and sotring parameters, but I want my own WriteIni method. There is also a problem with spaces around the equals sign.
A WriteParameter method is not overloaded because
Date, Time, and DateTimeall pass parameters as TDateTime. The ReadParameter method can not be overloaded because only the return type changes.
Purpose of the ini component
Easy to use
Read command line prarameters (name of ini file)
Read ini parameters
Command line parameters should take priority
Write ini parameters and keep comments and spacing
Ignore spaces around "="
On save, maintain spaces around "="
Saves ini, command line, default, current parameters
If any parameters are "changed", a flag is set
so that "save" is enabled in the menu
A way to create parameters and defaults at design time
Other components need to call this and to store defaults
Allow parameters which are not in the ini file
Save any parameter set "by the user"
Parameters with the default value or the command line value
are not "added" to the ini file
Store comments in the string list with a comment flag
This should simplify writing an ini file
Allows inclusion of an ini file developer (just use a memo field)
Don't do this - makes maintaining spaces difficult
Allows comments to be added to parameters not yet in ini file
then comments can be generated when parameter is added
The Delphi ini component has no way to store default values
Over riding the "readString" command won't work because
the other "read" commands pass a null string as the default parameter
Allowing blank lines and comments in the string list will
slow down searches
Provide a way to see what changes have been made
Read ini file into a stringlist
Search for "[section]" to get start of search
search for "[" to get end of search
Find line which starts with "name"
Use this stringlist when you write a new ini file
(keeps from having to read the file again)
This could be a problem with large ini files
(mine tend to be 2K, ie size is not an issue)
Some ini files may NOT have sections
Command line parameters can only apply to parameters without sections
unless special code is written
Author: Robert Clemenzi -
clemenzi@cpcug.org