In this section, we will describe some of functions used to manipulate Arrays on FMScript.
FMscript propose two differents to initialise arrays: ArrayItemAdd and ArrayInsertValue
creates an array named 'ArrayName' (if it does not exist) and adds the elements as in a stack
Signature
ArrayItemAdd(ArrayName : String, ItemStr : String);
var Result : String;
ArrayItemAdd('MyEngeneersArray', 'Richie');
ArrayItemAdd('MyEngeneersArray', 'Georges');
Exit;
creates an array named 'ArrayName' (if it does not exist) and adds the elements to the specified index
Signature
ArrayInsertValue(ArrayName : String, APosition : Integer, PositionValue : String);
var Result : String;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
Exit;
Return string value at APosition in the array
Signature
ArrayGetValue(ArrayName : String, APosition : Integer);
var Result : String;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
ShowMessage(ArrayGetValue('MyEngeneersArray', 0));
Exit;
Return the index if SearchStr found in array, if not found the return -1
Signature
ArrayIndexOf(ArrayName : String, SearchStr : String);
var Result : String;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
ShowMessage(ArrayIndexOf('MyEngeneersArray', 'Richie'));
Exit;
Return ItemsCount of ArrayName
Signature
ArrayItemsCount(ArrayName : String);
VAR Result : String;
VAR Count : Integer;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
Count := ArrayItemsCount('MyEngeneersArray');
ShowMessage('Count = ' + IntToStr(Count));
Exit;
Return ItemsCount of ArrayName
Signature
ArrayItemRemove(ArrayName : String, Position : Integer);
VAR Result : String;
VAR Count : Integer;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
Count := ArrayItemsCount('MyEngeneersArray');
ShowMessage('Count Before = ' + IntToStr(Count));
//--remove
ArrayItemRemove('MyEngeneersArray',1);
Count := ArrayItemsCount('MyEngeneersArray');
ShowMessage('Count After = ' + IntToStr(Count));
Exit;
Clear Array Items and Return 1,XXX if success or 0,XXX if failed.
Signature
ArrayItemsClear(ArrayName : String);
VAR Result : String;
VAR Count : Integer;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
//--Clear
ArrayItemsClear('MyEngeneersArray');
Exit;
Return concatenated ArrayName items with ADelimiter as a string.
Signature
ArrayToStr(ArrayName : String, ADelimiter : String);
VAR Result : String;
VAR ValueStr : String;
VAR Count : Integer;
ArrayInsertValue('MyEngeneersArray', 0 , 'Richie');
ArrayInsertValue('MyEngeneersArray', 1 , 'Georges');
//--Convert
ValueStr := ArrayToStr('MyEngeneersArray',';');
ShowMessage(ValueStr);
Exit;
Split a string to an array.
Signature
StrToArray(ArrayName : String, StringName : String, Delimiter : String);
VAR Result : String;
VAR ValueStr : String;
VAR Count : Integer;
ValueStr := 'FM IS THE BEST';
//--Convert
StrToArray('MyEngeneersArray',ValueStr, ' ');
Count := ArrayItemsCount('MyEngeneersArray');
ShowMessage('Count = ' + IntToStr(Count));
Exit;
Return min value in ArrayName if all values are numeric.
Signature
ArrayGetMinValue(ArrayName : String);
Return max value in ArrayName if all values are numeric.
Signature
ArrayGetMaxValue(ArrayName : String);