RosettaCodeData/Task/Address-of-a-variable/S-BASIC/address-of-a-variable.basic
2024-10-16 18:07:41 -07:00

22 lines
649 B
Text

comment
The LOCATION statement (with its somewhat counter-
intuitive syntax) is used to obtain the address
of a variable. A variable may be placed at a
particular memory address by declaring it as BASED and
then positioning it at run-time using the BASE..AT
statement. Most often this is done to access the values
stored in operating system variables and structures,
though it has other uses as well.
end
var i, address_of_i = integer
based k = integer
location var address_of_i = i
print "The variable i is stored at "; hex$(address_of_i)
base k at address_of_i
i = 12345
print "i ="; i
print "k ="; k rem - same as i
end