A little proof of concept method for a bigger program that I'm playing around with, which allows us to reference variables by offset rather than by name.
Take a moment and be certain to notice that these are 3 different type variables all being processed and altered via the same SUB.
Code: (Select All)
Dim foo As Integer
Dim foo2 As _Unsigned _Byte
Dim foo3 As Long
Print foo, foo2, foo3
ToggleVar _Offset(foo), Len(foo)
ToggleVar _Offset(foo2), Len(foo2)
ToggleVar _Offset(foo3), Len(foo3)
Print foo, foo2, foo3
ToggleVar _Offset(foo), Len(foo)
ToggleVar _Offset(foo2), Len(foo2)
ToggleVar _Offset(foo3), Len(foo3)
Print foo, foo2, foo3
Sub ToggleVar (variable_offset As _Offset, variable_size As _Byte)
Static m As _MEM
m = _Mem(variable_offset, variable_size)
Select Case variable_size
Case 1
temp%% = _MemGet(m, m.OFFSET, _Byte)
_MemPut m, m.OFFSET, Not temp%% As _BYTE
Case 2
temp% = _MemGet(m, m.OFFSET, Integer)
_MemPut m, m.OFFSET, Not temp% As INTEGER
Case 4
temp& = _MemGet(m, m.OFFSET, Long)
_MemPut m, m.OFFSET, Not temp& As LONG
Case 8
temp&& = _MemGet(m, m.OFFSET, _Integer64)
_MemPut m, m.OFFSET, Not temp&& As _INTEGER64
End Select
End Sub
Take a moment and be certain to notice that these are 3 different type variables all being processed and altered via the same SUB.