
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.




 
Dim TheAddress as long
Dim SecVar as byte
Dim MyVar as byte
    MyVar = 10
 
'Get the address of MyVar
TheAddress = varptr(MyVar)
 
'Set a new value on the address
MEMSET(TheAddress, 102, SizeOf(byte))
 
'Myvar is now = 102
showmessage "MyVar = " + str$(MyVar)
 
'...or copy from one address to another using:
MEMCPY(VarPtr(SecVar), TheAddress, SizeOf(byte))
 
'SecVar is now also = 102
showmessage "SecVar = " + str$(SecVar)
 