<< Click to Display Table of Contents >> Navigation: FindOnClick > FindOnClick For Advanced Users > Scripting > Classes |
A number of built-in scripting classes are available. See also Script Functions.
TEnumVariant
TEnumVariant is a helper class for collections, e.g. FileSystemObject.Drives
Create the object by passing the collection. Then you call ForEach to get each item in the collection. For example:
//
// Return the list of drives
//
DrivesEnum:=TEnumVariant.Create(gFSO.Drives);
try
while DrivesEnum.ForEach(DiskDrive) do begin
If (DiskDrive.IsReady = TRUE) then
If not SBLocation.AddDir(DiskDrive.DriveLetter) then
Exit;
end;
finally
DrivesEnum.Free;
end;
See the AllDrives.pas example script for an example.
TFileList
This class is for storing sorted lists of filenames with an optional signed 32-bit integer value. It is not case-sensitive. Each entry has a unique index, with the first index being zero (0). When an item is added or removed then the indexes may change.
This class is useful to keep track of filenames and how many times they have been found, for example.
constructor TFileList.Create(Type);
Type: The type of filenames stored:
EFLT_None: No type, so they can be any kind of string, not just filenames
EFLT_FullPath: The filename is the full path, e.g. C:\folder\filename.txt
EFLT_JustFilenames: The filename is just the filename, e.g. filename.txt
function TFileList.Add(Filename);
Filename: The filename to add to the list and given a value of 1. If the filename is already in the list then nothing is done.
Return value: The index of the entry.
function TFileList.AddInc(Filename);
Filename: The filename to add to the list. If the filename is already in the list then it's value is incremented by one.
Return value: The index of the entry.
function TFileList.AddWithValue(Filename, Value);
Filename: The filename to add to the list.
Value: The value to give the entry.
Return value: The index of the entry.
If the filename is already in the list then the value is set for the existing entry.
procedure TFileList.Remove(Filename);
Filename: The filename to remove from the list.
procedure TFileList.RemoveNotValue(Value);
Value: All items that do not have the specified value are removed from the list.
procedure TFileList.RemoveValue(Value);
Value: All items that have the specified value are removed from the list.
procedure TFileList.RemoveLowerThan(Value);
Value: All items that have a value lower than the specified value are removed from the list.
procedure TFileList.RemoveHigherThan(Value);
Value: All items that have a value higher than the specified value are removed from the list.
procedure TFileList.Delete(Index);
Index: The filename to remove from the list based on its index (the list is zero based).
procedure TFileList.Clear;
The list is clear, i.e. all filenames are removed from the list.
property TFileList.Count;
Return value: The number of filenames in the list, or zero if it is empty. Note that this is not a total value of the values for all the files in the list.
function TFileList.Exists(Filename);
Filename: The filename to check if it exists in the list.
Return value: The index of the entry, or -1 if the filename is not in the list.
function TFileList.ExistsGetValue(Filename, var Value);
Filename: The filename to check if it exists in the list.
Value: If the filename exists in the list then the value of the filename is returned. Ignore this value if -1 is returned.
Return value: The index of the entry (and Value is set), or -1 if the filename is not in the list.
procedure TFileList.SaveToFile(Filename);
Filename: The file to save the list to
The contents of the list will be save to a comma-delimited text file. Each filename in the list is wrapped in double-quotes.
procedure TFileList.LoadFromFile(Filename);
Filename: The file to load the list from (replacing the existing entries in the list)
The text file will be loaded and placed into the list. If there is no value (or it's invalid) for a filename entry, then it is set to zero.
property TFileList.Filename[Index];
Index: The filename to retrieve from the list based on its index (the list is zero based).
Return value: The filename
property TFileList.Value[Index];
Index: The value to retrieve from the list based on its index (the list is zero based).
Return value: The value
property TFileList.Highest;
Return value: The highest value in the list, or -1 if the list is empty.
property TFileList.Lowest;
Return value: The lowest value in the list, or MaxInt if the list is empty.
<%SBCOPYRIGHT%>