Dystlab software has its own scripting engine (Scripter) that supports Pascal and Basic programming languages. Scripter can be used to develop applications, draw frames in reports, graphical visualizations, and more.
System procedures and functions
These procedures and functions can be used in all types of documents, regardless of their purpose.
Abs
Function: function Abs(X: Real): Real;
Description: Returns the absolute value of a number.
Example: Result := Abs(-5.5); // Result = 5.5
AnsiCompareStr
Function: function AnsiCompareStr(const S1, S2: string): Integer;
Description: Compares two strings case-sensitively.
Example: Result := AnsiCompareStr('Hello', 'hello'); // Result < 0
AnsiCompareText
Function: function AnsiCompareText(const S1, S2: string): Integer;
Description: Compares two strings case-insensitively.
Example: Result := AnsiCompareText('Hello', 'hello'); // Result = 0
AnsiLowerCase
Function: function AnsiLowerCase(const S: string): string;
Description: Converts a string to lowercase.
Example: Result := AnsiLowerCase('Hello'); // Result = 'hello'
AnsiUpperCase
Function: function AnsiUpperCase(const S: string): string;
Description: Converts a string to uppercase.
Example: Result := AnsiUpperCase('Hello'); // Result = 'HELLO'
Append
Procedure: procedure Append(var F: Text);
Description: Opens an existing file for appending text.
Example: Append(MyFile);
ArcTan
Function: function ArcTan(X: Real): Real;
Description: Returns the arctangent of a number.
Example: Result := ArcTan(1); // Result = 0.7854
Assigned
Function: function Assigned(P: Pointer): Boolean;
Description: Checks if a pointer is not nil.
Example: if Assigned(MyPointer) then ...
AssignFile
Procedure: procedure AssignFile(var F: File; const FileName: string);
Description: Assigns a file name to a file variable.
Example: AssignFile(MyFile, 'test.txt');
Beep
Procedure: procedure Beep;
Description: Produces a beep sound.
Example: Beep;
ChDir
Procedure: procedure ChDir(const Dir: string);
Description: Changes the current directory.
Example: ChDir('C:\Windows');
Chr
Function: function Chr(X: Byte): Char;
Description: Returns the character with the specified ASCII code.
Example: Result := Chr(65); // Result = 'A'
CloseFile
Procedure: procedure CloseFile(var F: File);
Description: Closes an open file.
Example: CloseFile(MyFile);
CompareStr
Function: function CompareStr(const S1, S2: string): Integer;
Description: Compares two strings case-sensitively.
Example: Result := CompareStr('Hello', 'hello'); // Result < 0
CompareText
Function: function CompareText(const S1, S2: string): Integer;
Description: Compares two strings case-insensitively.
Example: Result := CompareText('Hello', 'hello'); // Result = 0
Copy
Function: function Copy(const S: string; Index, Count: Integer): string;
Description: Returns a substring of a string.
Example: Result := Copy('Hello World', 7, 5); // Result = 'World'
Cos
Function: function Cos(X: Real): Real;
Description: Returns the cosine of an angle.
Example: Result := Cos(0); // Result = 1
CreateOleObject
Function: function CreateOleObject(const ClassName: string): IDispatch;
Description: Creates an OLE automation object.
Example: ExcelApp := CreateOleObject('Excel.Application');
Date
Function: function Date: TDateTime;
Description: Returns the current date.
Example: Result := Date; // Result = current date
DateTimeToStr
Function: function DateTimeToStr(DateTime: TDateTime): string;
Description: Converts a TDateTime value to a string.
Example: Result := DateTimeToStr(Now); // Result = current date and time as string
DateToStr
Function: function DateToStr(Date: TDateTime): string;
Description: Converts a TDateTime value to a date string.
Example: Result := DateToStr(Date); // Result = current date as string
DayOfWeek
Function: function DayOfWeek(Date: TDateTime): Integer;
Description: Returns the day of the week for a given date.
Example: Result := DayOfWeek(Date); // Result = day of the week (1-7)
Dec
Procedure: procedure Dec(var X: Integer; N: Integer = 1);
Description: Decrements a variable by a specified value.
Example: Dec(MyVar); // MyVar = MyVar - 1
DecodeDate
Procedure: procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
Description: Extracts the year, month, and day from a TDateTime value.
Example: DecodeDate(Date, Year, Month, Day);
DecodeTime
Procedure: procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);
Description: Extracts the hour, minute, second, and millisecond from a TDateTime value.
Example: DecodeTime(Now, Hour, Min, Sec, MSec);
Delete
Procedure: procedure Delete(var S: string; Index, Count: Integer);
Description: Deletes a substring from a string.
Example: Delete(MyString, 5, 3); // Removes 3 characters starting at position 5
EncodeDate
Function: function EncodeDate(Year, Month, Day: Word): TDateTime;
Description: Creates a TDateTime value from year, month, and day.
Example: Result := EncodeDate(2023, 10, 5); // Result = TDateTime for October 5, 2023
EncodeTime
Function: function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
Description: Creates a TDateTime value from hour, minute, second, and millisecond.
Example: Result := EncodeTime(12, 30, 0, 0); // Result = TDateTime for 12:30:00.000
EOF
Function: function EOF(var F: Text): Boolean;
Description: Checks if the end of a file has been reached.
Example: if EOF(MyFile) then ...
Exp
Function: function Exp(X: Real): Real;
Description: Returns the exponential of a number.
Example: Result := Exp(1); // Result = 2.71828
FilePos
Function: function FilePos(var F: File): LongInt;
Description: Returns the current position in a file.
Example: Result := FilePos(MyFile); // Result = current file position
FileSize
Function: function FileSize(var F: File): LongInt;
Description: Returns the size of a file.
Example: Result := FileSize(MyFile); // Result = size of the file
FloatToStr
Function: function FloatToStr(Value: Extended): string;
Description: Converts a floating-point number to a string.
Example: Result := FloatToStr(3.14); // Result = '3.14'
Format
Function: function Format(const Format: string; const Args: array of const): string;
Description: Formats a string with given arguments.
Example: Result := Format('Hello, %s!', ['World']); // Result = 'Hello, World!'
FormatDateTime
Function: function FormatDateTime(const Format: string; DateTime: TDateTime): string;
Description: Formats a TDateTime value as a string.
Example: Result := FormatDateTime('yyyy-mm-dd', Now); // Result = current date in 'yyyy-mm-dd' format
FormatFloat
Function: function FormatFloat(const Format: string; Value: Extended): string;
Description: Formats a floating-point number as a string.
Example: Result := FormatFloat('0.00', 3.14159); // Result = '3.14'
Frac
Function: function Frac(X: Real): Real;
Description: Returns the fractional part of a number.
Example: Result := Frac(3.14); // Result = 0.14
GetActiveOleObject
Function: function GetActiveOleObject(const ClassName: string): IDispatch;
Description: Retrieves an active OLE automation object.
Example: ExcelApp := GetActiveOleObject('Excel.Application');
High
Function: function High(X: array or type): Integer;
Description: Returns the highest index of an array or the highest value of an ordinal type.
Example: Result := High(MyArray); // Result = highest index of MyArray
Inc
Procedure: procedure Inc(var X: Integer; N: Integer = 1);
Description: Increments a variable by a specified value.
Example: Inc(MyVar); // MyVar = MyVar + 1
IncMonth
Function: function IncMonth(const Date: TDateTime; NumberOfMonths: Integer = 1): TDateTime;
Description: Adds a specified number of months to a date.
Example: Result := IncMonth(Date, 2); // Result = current date + 2 months
InputQuery
Function: function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
Description: Displays a dialog box with a prompt and an input field, allowing the user to enter a string value.
Example:
var
UserInput: string;
begin
if InputQuery('Input', 'Enter your name:', UserInput) then
ShowMessage('Hello, ' + UserInput);
end;
Insert
Procedure: procedure Insert(const Source: string; var S: string; Index: Integer);
Description: Inserts a substring into a string at a specified position.
Example:
var
S: string;
begin
S := 'HelloWorld';
Insert(' ', S, 6);
ShowMessage(S); // Output: 'Hello World'
end;
Int
Function: function Int(X: Extended): Extended;
Description: Returns the integer part of a floating-point number.
Example:
var
Num: Extended;
begin
Num := Int(123.456);
ShowMessage(FloatToStr(Num)); // Output: '123'
end;
IntToHex
Function: function IntToHex(Value: Integer; Digits: Integer): string;
Description: Converts an integer to a hexadecimal string representation.
Example:
var
HexStr: string;
begin
HexStr := IntToHex(255, 4);
ShowMessage(HexStr); // Output: '00FF'
end;
IntToStr
Function: function IntToStr(Value: Integer): string;
Description: Converts an integer to a string.
Example:
var
Str: string;
begin
Str := IntToStr(123);
ShowMessage(Str); // Output: '123'
end;
IsLeapYear
Function: function IsLeapYear(Year: Word): Boolean;
Description: Checks if a given year is a leap year.
Example:
var
IsLeap: Boolean;
begin
IsLeap := IsLeapYear(2020);
ShowMessage(BoolToStr(IsLeap, True)); // Output: 'True'
end;
IsValidIdent
Function: function IsValidIdent(const Ident: string): Boolean;
Description: Checks if a string is a valid Pascal identifier.
Example:
var
Valid: Boolean;
begin
Valid := IsValidIdent('MyVar');
ShowMessage(BoolToStr(Valid, True)); // Output: 'True'
end;
Length
Function: function Length(S: string): Integer;
Description: Returns the length of a string.
Example:
var
Len: Integer;
begin
Len := Length('Hello');
ShowMessage(IntToStr(Len)); // Output: '5'
end;
Ln
Function: function Ln(X: Extended): Extended;
Description: Returns the natural logarithm of a number.
Example:
var
LogVal: Extended;
begin
LogVal := Ln(10);
ShowMessage(FloatToStr(LogVal)); // Output: '2.30258509299405'
end;
Low
Function: function Low(X: array or type): Integer;
Description: Returns the lowest index of an array or the lowest value of an ordinal type.
Example:
var
Arr: array[1..5] of Integer;
LowIndex: Integer;
begin
LowIndex := Low(Arr);
ShowMessage(IntToStr(LowIndex)); // Output: '1'
end;
LowerCase
Function: function LowerCase(const S: string): string;
Description: Converts a string to lowercase.
Example:
var
LowerStr: string;
begin
LowerStr := LowerCase('Hello World');
ShowMessage(LowerStr); // Output: 'hello world'
end;
Now
Function: function Now: TDateTime;
Description: Returns the current date and time.
Example:
var
CurrentTime: TDateTime;
begin
CurrentTime := Now;
ShowMessage(DateTimeToStr(CurrentTime)); // Output: Current date and time
end;
Odd
Function: function Odd(Value: Integer): Boolean;
Description: Checks if an integer is odd.
Example:
var
IsOdd: Boolean;
begin
IsOdd := Odd(3);
ShowMessage(BoolToStr(IsOdd, True)); // Output: 'True'
end;
Ord
Function: function Ord(X: Ordinal type): Integer;
Description: Returns the ordinal value of an ordinal type.
Example:
var
OrdVal: Integer;
begin
OrdVal := Ord('A');
ShowMessage(IntToStr(OrdVal)); // Output: '65'
end;
Pos
Function: function Pos(const SubStr, S: string): Integer;
Description: Returns the position of a substring within a string.
Example:
var
Position: Integer;
begin
Position := Pos('World', 'Hello World');
ShowMessage(IntToStr(Position)); // Output: '7'
end;
Raise
Procedure: procedure Raise Exception;
Description: Raises an exception.
Example:
begin
raise Exception.Create('An error occurred');
end;
Random
Function: function Random(Range: Integer): Integer;
Description: Generates a random integer within a specified range.
Example:
var
RandNum: Integer;
begin
RandNum := Random(100);
ShowMessage(IntToStr(RandNum)); // Output: Random number between 0 and 99
end;
ReadLn
Procedure: procedure ReadLn(var F: Text; var S: string);
Description: Reads a line of text from a file or standard input.
Example:
var
Input: string;
begin
Write('Enter your name: ');
ReadLn(Input);
ShowMessage('Hello, ' + Input);
end;
Reset
Procedure: procedure Reset(var F: File);
Description: Opens a file for reading.
Example:
var
F: TextFile;
S: string;
begin
AssignFile(F, 'test.txt');
Reset(F);
ReadLn(F, S);
ShowMessage(S);
CloseFile(F);
end;
Rewrite
Procedure: procedure Rewrite(var F: File);
Description: Opens a file for writing, erasing any existing content.
Example:
var
F: TextFile;
begin
AssignFile(F, 'test.txt');
Rewrite(F);
WriteLn(F, 'Hello, World!');
CloseFile(F);
end;
Round
Function: function Round(X: Extended): Int64;
Description: Rounds a floating-point number to the nearest integer.
Example:
var
Rounded: Int64;
begin
Rounded := Round(123.456);
ShowMessage(IntToStr(Rounded)); // Output: '123'
end;
ShowMessage
Procedure: procedure ShowMessage(const Msg: string);
Description: Displays a message box with the specified text.
Example:
begin
ShowMessage('Hello, World!');
end;
Sin
Function: function Sin(X: Extended): Extended;
Description: Returns the sine of an angle in radians.
Example:
var
SineVal: Extended;
begin
SineVal := Sin(Pi / 2);
ShowMessage(FloatToStr(SineVal)); // Output: '1'
end;
Sqr
Function: function Sqr(X: Extended): Extended;
Description: Returns the square of a number.
Example:
var
Square: Extended;
begin
Square := Sqr(4);
ShowMessage(FloatToStr(Square)); // Output: '16'
end;
Sqrt
Function: function Sqrt(X: Extended): Extended;
Description: Returns the square root of a number.
Example:
var
SqrtVal: Extended;
begin
SqrtVal := Sqrt(16);
ShowMessage(FloatToStr(SqrtVal)); // Output: '4'
end;
StrToDate
Function: function StrToDate(const S: string): TDateTime;
Description: Converts a string to a date.
Example:
var
Date: TDateTime;
begin
Date := StrToDate('2023-10-01');
ShowMessage(DateToStr(Date)); // Output: '10/01/2023'
end;
StrToDateTime
Function: function StrToDateTime(const S: string): TDateTime;
Description: Converts a string to a date and time.
Example:
var
DateTime: TDateTime;
begin
DateTime := StrToDateTime('2023-10-01 12:34:56');
ShowMessage(DateTimeToStr(DateTime)); // Output: '10/01/2023 12:34:56 PM'
end;
StrToFloat
Function: function StrToFloat(const S: string): Extended;
Description: Converts a string to a floating-point number.
Example:
var
FloatVal: Extended;
begin
FloatVal := StrToFloat('123.456');
ShowMessage(FloatToStr(FloatVal)); // Output: '123.456'
end;
StrToInt
Function: function StrToInt(const S: string): Integer;
Description: Converts a string to an integer.
Example:
var
IntVal: Integer;
begin
IntVal := StrToInt('123');
ShowMessage(IntToStr(IntVal)); // Output: '123'
end;
StrToIntDef
Function: function StrToIntDef(const S: string; Default: Integer): Integer;
Description: Converts a string to an integer, with a default value if the conversion fails.
Example:
var
IntVal: Integer;
begin
IntVal := StrToIntDef('ABC', 0);
ShowMessage(IntToStr(IntVal)); // Output: '0'
end;
StrToTime
Function: function StrToTime(const S: string): TDateTime;
Description: Converts a string to a time.
Example:
var
TimeVal: TDateTime;
begin
TimeVal := StrToTime('12:34:56');
ShowMessage(TimeToStr(TimeVal)); // Output: '12:34:56 PM'
end;
Time
Function: function Time: TDateTime;
Description: Returns the current time.
Example:
var
CurrentTime: TDateTime;
begin
CurrentTime := Time;
ShowMessage(TimeToStr(CurrentTime)); // Output: Current time
end;
TimeToStr
Function: function TimeToStr(Time: TDateTime): string;
Description: Converts a time to a string.
Example:
var
TimeStr: string;
begin
TimeStr := TimeToStr(Now);
ShowMessage(TimeStr); // Output: Current time as a string
end;
Trim
Function: function Trim(const S: string): string;
Description: Removes leading and trailing whitespace characters from a string.
Example:
var Str: string; begin Str := ' Hello, World! '; Str := Trim(Str); // Str becomes 'Hello, World!' end;
TrimLeft
Function: function TrimLeft(const S: string): string;
Description: Removes leading whitespace characters from a string.
Example:
var Str: string; begin Str := ' Hello, World!'; Str := TrimLeft(Str); // Str becomes 'Hello, World!' end;
TrimRight
Function: function TrimRight(const S: string): string;
Description: Removes trailing whitespace characters from a string.
Example:
var Str: string; begin Str := 'Hello, World! '; Str := TrimRight(Str); // Str becomes 'Hello, World!' end;
Trunc
Function: function Trunc(X: Real): Int64;
Description: Truncates a real number to an integer by removing the fractional part.
Example:
var Num: Int64; begin Num := Trunc(123.456); // Num becomes 123 end;
UpperCase
Function: function UpperCase(const S: string): string;
Description: Converts a string to uppercase.
Example:
var Str: string; begin Str := 'Hello, World!'; Str := UpperCase(Str); // Str becomes 'HELLO, WORLD!' end;
VarArrayCreate
Function: function VarArrayCreate(const Bounds: array of Integer; VarType: Integer): Variant;
Description: Creates a variant array with the specified bounds and type.
Example:
var Arr: Variant; begin Arr := VarArrayCreate([0, 9], varInteger); // Creates a 10-element integer array end;
VarArrayHighBound
Function: function VarArrayHighBound(const A: Variant; Dim: Integer): Integer;
Description: Returns the upper bound of a specific dimension in a variant array.
Example:
var HighBound: Integer; Arr: Variant; begin Arr := VarArrayCreate([0, 9], varInteger); HighBound := VarArrayHighBound(Arr, 1); // HighBound becomes 9 end;
VarArrayLowBound
Function: function VarArrayLowBound(const A: Variant; Dim: Integer): Integer;
Description: Returns the lower bound of a specific dimension in a variant array.
Example:
var LowBound: Integer; Arr: Variant; begin Arr := VarArrayCreate([0, 9], varInteger); LowBound := VarArrayLowBound(Arr, 1); // LowBound becomes 0 end;
VarIsNull
Function: function VarIsNull(const V: Variant): Boolean;
Description: Checks if a variant is null.
Example:
var IsNull: Boolean; V: Variant; begin V := Null; IsNull := VarIsNull(V); // IsNull becomes True end;
VarToStr
Function: function VarToStr(const V: Variant): string;
Description: Converts a variant to a string.
Example:
var Str: string; V: Variant; begin V := 123.45; Str := VarToStr(V); // Str becomes '123.45' end;
Write
Procedure: procedure Write([var F: Text;] P1 [, P2, ..., Pn]);
Description: Writes data to a text file or the console without a newline.
Example:
begin
Write('Hello, '); // Outputs 'Hello, ' to the console
Write('World!'); // Outputs 'World!' to the console
end;
WriteLn
Procedure: procedure WriteLn([var F: Text;] P1 [, P2, ..., Pn]);
Description: Writes data to a text file or the console and appends a newline.
Example:
begin
WriteLn('Hello, World!'); // Outputs 'Hello, World!' followed by a newline
end;

