User guide

22
VTB USER GUIDE
6.3 Pointers
VTB is able to manage the pointers to variables too. Pointers defines the address of allocation memory of the variables,
not its content. Some VTB functions need of pointers as parameter particularly when the function manage arrays or
strings. To define the address of a variable it's enough insert the postfix () except for the funcions.
Example:
var as long
array(20) as uint
var() ‘refers to the address of variable var
array() ‘refers to the address of the first element of array
Pointers can be declared only to following types:
Char, Uchar, Int, Uint, Long, Float, Functions
Declaring of a pointer
To assign an address to the pointer it's need:
refer to the name of pointer (without brakes)
assign the desired address to pointer
To assign the value to a pointed field it's need:
refer to the pointer with square brackets
put the right index inside the brackets
assign the value
Examples
Used variables:
pnt as *long
val as long
pointer as *uint
array(10) as uint
var as long
Writing/reading variables by pointer:
pnt=val() 'assign to pnt the address of variable val
pnt[0]=2000 ’ pnt[0] points to variable val which will take the value 2000
var=punt[0] 'assign to var the content of val by the pointer pnt
Writing/reading array by pointer:
pointer=array() ‘assign to pointer the address of array
pointer[0]=13
pointer[1]=27
pointer[9]=55 ‘ assign to array some value by pointer
var=pointer[7] ‘ assign to var the content of array[7]