User manual
mikroBasic PRO for PIC32
MikroElektronika
207
Sample = MyPtr^(1, 2, 3) ‘ Perform function call via pointer, call Func1, the return
value is 3
MyPtr = @Func2 ‘ MyPtr now points to Func2
Sample = MyPtr^(1, 2, 3) ‘ Perform function call via pointer, call Func2, the return
value is 5
MyPtr = @Func3 ‘ MyPtr now points to Func3
Sample = MyPtr^(1, 2, 3) ‘ Perform function call via pointer, call Func3, the return
value is 0
end.
@ Operator
The @ operator constructs a pointer to its operand. The following rules are applied to @:
- If X is a variable, @X returns a pointer to X.
Note: If variable X is of array type, the @ operator will return pointer to it’s rst basic element, except when the left
side of the statement in which X is used is an array pointer.
In this case, the @ operator will return pointer to array, not to it’s rst basic element.
program example
dim w as word
ptr_b as ^byte
ptr_arr as ^byte[10]
arr as byte[10]
main:
ptr_b = @arr ‘ @ operator will return ^byte
w = @arr ‘ @ operator will return ^byte
ptr_arr = @arr ‘ @ operator will return ^byte[10]
end.
- If F is a routine (a function or procedure), @F returns a pointer to F.
Related topics: Pointer Arithmetic