Some Action properties are of type TStrings. TStrings is a standard Delphi type that we have exposed to the scripting engine. It is basically a string collection. Below are the properties of TStrings that you will find useful:

Method CallExampleDescription
procedure Clear;
Action.ListOfItems.Clear;
Clears the TStrings object of all the strings it contains.
function Add(const text: string): Integer;
var index = Action.ListOfItems.Add('Item 5');
Appends a string to the end of the list of string the TStrings object contains. The index of the newly added text is returned.
procedure Delete(index: Integer);
Action.ListOfItems.Delete(5);
Deletes the string located at the passed in index. If the index does not exist and error is generated.
procedure Insert(index: Integer; const text: string);
Action.ListOfItems.Insert(5, 'Item 5');
Inserts the passed in text at the passed in index. If the index is outside the bounds of the list which the TStrings object holds and error is generated.
function IndexOf(const text: string): Integer;
Action.ListOfItems.IndexOf('Item 5');
Returns the index of the passed in string. If it doesn't exist in the list of string held by the TStrings object, -1 is returned.
property Strings[index: Integer]: string; 
var item5Text = Action.ListOfItems.Strings[5];
Returns the text held at the passed in index. The index is zero based. If the index does not exist in the current list of string help by the TStrings object an error is raised.
property Count: Integer;
var count = Action.ListOfItems.Count;
Returns the number of string held by the TStrings object.
property Text: string; 
var list = Action.ListOfItems.Text;
Returns all the strings in the collection, each entry on a new line.
property Names[index: Integer]: string;  
var item5Name = Action.ListOfItems.Names[5];
Returns the name string held by the TStrings object at the passed in index. Strings can be stored in name=value pairs. This method allows access to the name part when this storage method is used.
property Values[name: String]: string; 
var item5Value = Action.ListOfItems.Values[item5Name];
Returns the value string held by the TStrings object for the passed in name. Strings can be stored in name=value pairs. This method allows access to the value part when this storage method is used.
property ValueFromIndex[index: Integer] : string;
var item5Value = Action.ListOfItems.ValueFromIndex[5];
Returns the value string help by the TStrings object for the passed in index. Strings can be stored in name=value pairs. This method allows access to the value part when this storage method is used.

Example

The following code reduces each item in a List Iterator's list of items down to its leftmost three characters:

  • No labels