Classes

<< Click to Display Table of Contents >>

Navigation:  Using SyncBackPro > Technical Reference > Scripting >

Classes

 

A number of built-in scripting classes are available. See also Script Functions.

 

All the example code below is written in using the Pascal scripting language.

 


Class 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.

 

 

Class TStringList

 

This class is for storing lists of strings. For more information refer to the Delphi help entry for TStringList.

 

function Example: String;

var

  s: TStringList; // IMPORTANT: Must define it as TStringList

  idx: Integer;

begin

  Result:='TESTING';

// s:=TStringList.Create;

  s:=TStringList.Create(dupError);

  s.CaseSensitive:=TRUE;

  s.Sorted:=TRUE;

  s.Duplicates:=dupError; // dupIgnore, dupAccept

  s.Add('DEF');

  s.Add('ABC');

  s.Add('abc');

  s.Delete(s.IndexOf('abc'));

  idx:=0; // IMPORTANT: Must set it to an integer value before calling .Find

  if s.Find('ABC', idx) then

    //Result:=s.Strings[idx]

    Result:=s[idx] // Does not work if just do var s;

  else

    Result:='Not found';

  s.Free;

end;

 

 

 

 

 

All Content: 2BrightSparks Pte Ltd © 2003-2024