|
|
Basic Script Structure
The Basic Script Structure is broken down into 4 main sections.
The Variables Section
A variable is a user-defined attribute against which you can evaluate and store an evaluated result for output or further action. Multiple variables can be declared under a heading var. For Example:
Var
TheCustomerName: String;
TheInvoiceCount: integer;
ErrorFound : Boolean;
Each variable is declared using the same standard format;
VariableName your defined name – No Spaces
: Colon to denote the end of the VariableName
Format The Format of the data
; Semi-colon to denote end of variable
The more common Formats are:
String – AlphaNumeric characters
Double – Number with decimals
Integer – Number with no decimals
Boolean – True or False
However you can also use the following:
Byte: Same as Integer
Word: Same as Integer
Integer: Basic Integer (Whole numbers only)
Longint: Same as Integer
Cardinal: Same as Integer
Tcolor: Same as Integer
Boolean: Returns True or False
Real: Same as Extended
Single: Same as Extended
Double: Same as Extended
Extended: A floating point type with the highest capacity and precision
TDate: Data type holding a date value (Same as Extended type)
TTime: Data type holding a time value (Same as Extended type)
TDateTime: Data type holding a date and time value (Same as Extended type)
Char: Variable type holding a single character
String: A data type that holds a string of characters
Variant: A variable type that can hold changing data types
Array: An Array type
The Constants Section
A Constant is a user-defined value that can be referenced at any time within the script
Multiple Constants can be declared under a heading const. For Example:
Const
pi = 3.14159;
e = 2.71828496
Each constant is declared using the same standard format;
ConstantName your defined name – No Spaces
= Equals sign
Value The defined value of the constant
; Semi-colon to denote end of declared constant
The Main Process
The Main Process is a user-defined routine than performs a required activity. A simple example of a Main Process is:
var
MyValue: Integer;
begin
MyValue := 1;
Showmessage(Myvalue + Myvalue);
End.
You should note the following
A Var is only required if you are storing a result as opposed to the script (say) updating a record.
The process itself has a Begin and End Statement
Each instruction within the process ends with a semi-colon
The final End statement ends in a full-stop
The Procedure Section
If a process is used more than once within the script you can avoid retyping the process by declaring a Procedure. A Procedure is a user-defined routine than performs a required activity. This allows you to simply call the Procedure Name whenever you require this process to be carried out.
A procedure can comprise of its own declared Variables as well as the process itself, For example
procedure FirstProcedure;
var
MyValue: Integer;
begin
MyValue := 1;
Showmessage(Myvalue + Myvalue);
End;
Begin
FirstProcedure;
End.
Comments
A couple of notes to complete this introduction:
1. You can place comments in the script in one of two ways
// Anything on this line after the ‘double slash’ is ignored
{ Anything that is contained within ‘squiggly Brackets’ is ignored. This can go over many lines}
2. Pre-defined functions are ‘Procedures’ designed by Development-X that allow you enter simple information to perform a complex activity. These are shown in the next section