
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses




Task

Demonstrate how to get the address of a variable and how to set the address of a variable.




 
== Get ==
 
adr(variable)
 
Example:
 
dim a
print adr(a)
 
== Set ==
 
Whether Panoramic is able to set the value of a variable may depend on what is meant by that. Panoramic implements the
poke command to set a byte from a value of 0 to 255 (inclusive). Panoramic also implements the peek command to get
the value of a byte, so it is possible to the following:
 
(A)
dim a
rem a variable with no post-fix is a real. 
poke adr(a),57
rem the value of a variable being set by setting an address, the address of a in this instance.
 
(B)
dim a%,b%
rem % means integer.
b%=57
poke adr(a%),b%
rem b% being assigned to the address of a%, in this instance.
rem it is even possible to free b%
free b%
print a%
 
(C)
dim a,b
b=57
poke adr(a),b
b=peek(adr(a))
print b
rem the address of b being, in effect, set to the address of a, the address of a, in this instance.
 
rem Observations and further insight welcome.
 
''Note:'' An attempt to poke a real or an integer (Panoramic's only numeric types) value of less than 0 or of more than
255 will cause an error.
 