|
|
Topic complex |
Language elements |
Function |
VAR |
Short |
Defines a variable or a group of variables |
Syntax |
VAR Bezeichner {, Bezeichner} : Typ [= Ausdruck] |
Parameter |
type:
BYTE (number 0..255)
INTEGER (number -2147483648 to +2147483647)
REAL (floating point number with about 18 significant digits)
CHAR (1 character)
STRING (max 255 chararcters)
TBITS (1 Bit)
MARKS (marking list)
With all of this basic types also array with max 10 dimensions can be defined:
VAR Matrix : REAL[10,10]
The first field index is always 0
Expression: arithmetic expression of the specified type. |
Return |
|
See also: |
|
Description |
By specification of an expression all variables of the list are initialised with that value.
At present (Version 6.2.6) fields can not be initialised on this way. They are always initialised with 0 resp. the empty string.
Is no expression specified, the variables are initialised with the following values:
BYTE, INTEGER, REAL : 0
STRING, CHAR : ''
MARKS :
TBITS : reset Bit
Initialisation
The expression is not calculated and assigned when compiling but at runtime(!). That again means, that self defined functions can be used here. Therefor an example:
MODULE counter; // location: lib/counter.mod
PROCEDURE Init : REAL;
VAR result, ec_before : INTEGER;
ec_before:=getpara('ec'); setpara('ec 1');
result:=opendb("database/counter/counter.dat","",0,15);
setpara('ec '+str(ec_before));
IF result=0 THEN
cgiwriteln('content-type: text/html');
cgiwriteln('');
cgiwriteln('database-error: '+TDB_ErrorStr(TDB_LastError));
HALT
ELSE
RETURN result;
END
ENDPROC;
VAR db : INTEGER = Init;
If another programm accesses to that module, after
USES counter.mod;
a valid (and opened for writing) table handle (of the table database/counter/counter.dat) is available.
|
Write a comment:
|
|
|