When you specify it as a block of statements, your script must conform to the rules of the script language. It is like a pascal language.
You must conform to the following rules:
1. Each statement must end with a semicolon (;)
2. You can use the following statements:
variable := expression;
If logical expression then statement(s) [else statement(s)];
for variable := from_expression to/downto to_expression do statement(s);
while logical_expression do statement(s);
repeat statement(s) until logical_expression;
try statement(s) finally statement(s) end;
try statement(s) except statement(s) end;
inline comments // comment... until the end of the line
nested comments { nested comment }
Statement(s) in the above declarations states that you can specify either a single statement or a block of statements. The block of statements must be enclosed in begin ... end keywords. It is not necessary to enclose the body of the function in begin .. end. Cycle statements can use break keyword to break the cycle (
break must also end with semicolon ! ). In exception part of a try except end block, you can use ExceptObject function to get a reference to exception object.
Each function has a reserved local variable result, which is used to assign the result the function returns.
If you use a valid identifier name in the left part of the assignment statement or as a variable in a for cycle, which is not a variable within the scope of the function, a local variable is created automatically for you and initilized with zero (0), which is valid only within the body of the function. Thus, if you use somewhere in a script, i.e. a:=a+2; and 'a' is not declared as variable, first is creating a local variable 'a', initilized with zero, and then is perform evaluation, so that you can obtain always a valid results.
If you specify a function just as a single line function, you have not to use any of the above statements and rules. Only directly specify the expression without ending it with a semicolon (;), and not using assignment (:=) keyword nor the reserved local variable result.
Functions can use an arguments which are declared in expression as %number of argument (i.e. %0, %1, %2... and so on). Numbers of arguments are zero based, so %0 states for first argument, %1 for second, %2 for third and so on.
When an expression calls a function, it must supply all actual values for all function's arguments, separated by a comma (','). A function without arguments, must be called with an empty list of arguments, i.e DATE;
3. The elements of the variant array can be referenced, as usual:
vararray_variable_name[index],
i.e. V1