ErosOlmi
28-04-2007, 09:02
Some new vaporware but not so much because this functionality is already developed :D
Next thinBasic preview (out by 1st week of May) will have DIM ... AT fucntionality.
Syntax:
DIM VarName[(subscripts)] AS VarType [AT AbsoluteAddress] [ {VALUE | = | VALUE =} InitialValue ]
What is this?
When a varable is created (DIMensioned), thinBasic creates a special control structure that holds variable information plus thinBasic allocates a memory block big enough to hold variable data. This memory block will be than initialized to zero (if variable is numeric) or other pertinent initialization.
If DIM ... AT will be specified, only the special control structure will be create but no data memory block will be allocated. It will be presumed that at the Absolute memory address specified there will be a memory block ready to be used. Also no initialization will take place because some other process or some other variables will be in charge of that data memory block.
An example:
'---Define a standard numeric variable and assign some data
DIM MyLong AS LONG VALUE 1234
'---Now define a new variable of the same type but here set an absolute address
'---This new variable will share the same memory location of the first one
DIM MyNewLong AS LONG AT VARPTR(MyLong)
MSGBOX 0, MyLong '---This will print 1234
MyNewLong = 4321
MSGBOX 0, MyLong '---This will print 4321
Another example:
type MyType
X as single
Y as single
Z as single
end type
dim MyVar as MyType
dim MyNewVar(3) as single at varptr(MyVar)
MyVar.X = 1
MyVar.Y = 2
MyVar.Z = 3
msgbox 0, str$(MyVar.X) & str$(MyVar.Y) & str$(MyVar.Z)
MyNewVar(1) = 10
MyNewVar(2) = 20
MyNewVar(3) = 30
msgbox 0, str$(MyVar.X) & str$(MyVar.Y) & str$(MyVar.Z)
Those are just dummy examples but can give an idea of the power.
The same can be applied to more complex structures, to arrays or to pointers returned by external dll and mapped to script structures.
Just to let you know.
Ciao
Eros
Next thinBasic preview (out by 1st week of May) will have DIM ... AT fucntionality.
Syntax:
DIM VarName[(subscripts)] AS VarType [AT AbsoluteAddress] [ {VALUE | = | VALUE =} InitialValue ]
What is this?
When a varable is created (DIMensioned), thinBasic creates a special control structure that holds variable information plus thinBasic allocates a memory block big enough to hold variable data. This memory block will be than initialized to zero (if variable is numeric) or other pertinent initialization.
If DIM ... AT will be specified, only the special control structure will be create but no data memory block will be allocated. It will be presumed that at the Absolute memory address specified there will be a memory block ready to be used. Also no initialization will take place because some other process or some other variables will be in charge of that data memory block.
An example:
'---Define a standard numeric variable and assign some data
DIM MyLong AS LONG VALUE 1234
'---Now define a new variable of the same type but here set an absolute address
'---This new variable will share the same memory location of the first one
DIM MyNewLong AS LONG AT VARPTR(MyLong)
MSGBOX 0, MyLong '---This will print 1234
MyNewLong = 4321
MSGBOX 0, MyLong '---This will print 4321
Another example:
type MyType
X as single
Y as single
Z as single
end type
dim MyVar as MyType
dim MyNewVar(3) as single at varptr(MyVar)
MyVar.X = 1
MyVar.Y = 2
MyVar.Z = 3
msgbox 0, str$(MyVar.X) & str$(MyVar.Y) & str$(MyVar.Z)
MyNewVar(1) = 10
MyNewVar(2) = 20
MyNewVar(3) = 30
msgbox 0, str$(MyVar.X) & str$(MyVar.Y) & str$(MyVar.Z)
Those are just dummy examples but can give an idea of the power.
The same can be applied to more complex structures, to arrays or to pointers returned by external dll and mapped to script structures.
Just to let you know.
Ciao
Eros