ReneMiner
13-06-2013, 08:57
To make it short- is there a way to store/retrieve the pattern/structure of a datatype?
example:
' have two different types:
Type t_A
X as Byte
Y as Long
End Type
Type t_B
E as Ext
D as Double
End Type
' have some other type which can be a pointer to stored data of either type t_A or t_B
Type t_foo
theSubtype as ' unknown Type-Info
ptrSubType as Dword
End Type
Dim foo(2) as t_foo
foo(1).theSubtype = t_A
foo(1).ptrSubtype = Heap_Alloc(SizeOf(t_A)
foo(2).theSubtype = t_B
foo(2).ptrSubtype = Heap_Alloc(SizeOf(t_B)
'...call a sub/function which is part of some other, multiple usable .tBasicU
' to not too complicate it, this sub "knows" expression "foo" in this example
Sub InsideSub(Byval Index as Long)
' where index is foo's(Index)
Local data as foo(Index).theSubtype at foo(Index).ptrSubtype
End Sub
Now how can I replace/fill ".theSubtype" ? Is there a pointer or whatever to the type-defines/structures?
Can I use
thinBasic_VariableGetInfo()
'or
thinBasic_VariableGetInfoPtr()
'or
thinBasic_VariableGetInfoEx()
onto some dummy-variable of t_A or t_B
and how would that work to Dim As ... ?
Edit: other thought
' have two different types:
Type t_A
X As Byte
Y As Long
End Type
Type t_B
E As Ext
D As Double
End Type
' have some other type which can be a pointer to stored data of either type t_A or t_B
Type t_foo
theSubtype As Long
ptrSubType As DWord
End Type
Dim foo(2) As t_foo
' some empty dummy-array just borrow the name:
Dim bType(2) As Byte
Alias t_A As bType(1)
Alias t_B As bType(2)
' ---------------------------------------------------
' but no work: Alias only works on keywords...
' ---------------------------------------------------
foo(1).theSubtype = 1
foo(1).ptrSubtype = HEAP_Alloc(SizeOf(bType(foo(1).theSubtype)))
' ...
Sub InsideSub(ByVal Index As Long)
' where index is foo's(Index)
Local data As bType(foo(Index).theSubtype) At foo(Index).ptrSubtype
End Sub
example:
' have two different types:
Type t_A
X as Byte
Y as Long
End Type
Type t_B
E as Ext
D as Double
End Type
' have some other type which can be a pointer to stored data of either type t_A or t_B
Type t_foo
theSubtype as ' unknown Type-Info
ptrSubType as Dword
End Type
Dim foo(2) as t_foo
foo(1).theSubtype = t_A
foo(1).ptrSubtype = Heap_Alloc(SizeOf(t_A)
foo(2).theSubtype = t_B
foo(2).ptrSubtype = Heap_Alloc(SizeOf(t_B)
'...call a sub/function which is part of some other, multiple usable .tBasicU
' to not too complicate it, this sub "knows" expression "foo" in this example
Sub InsideSub(Byval Index as Long)
' where index is foo's(Index)
Local data as foo(Index).theSubtype at foo(Index).ptrSubtype
End Sub
Now how can I replace/fill ".theSubtype" ? Is there a pointer or whatever to the type-defines/structures?
Can I use
thinBasic_VariableGetInfo()
'or
thinBasic_VariableGetInfoPtr()
'or
thinBasic_VariableGetInfoEx()
onto some dummy-variable of t_A or t_B
and how would that work to Dim As ... ?
Edit: other thought
' have two different types:
Type t_A
X As Byte
Y As Long
End Type
Type t_B
E As Ext
D As Double
End Type
' have some other type which can be a pointer to stored data of either type t_A or t_B
Type t_foo
theSubtype As Long
ptrSubType As DWord
End Type
Dim foo(2) As t_foo
' some empty dummy-array just borrow the name:
Dim bType(2) As Byte
Alias t_A As bType(1)
Alias t_B As bType(2)
' ---------------------------------------------------
' but no work: Alias only works on keywords...
' ---------------------------------------------------
foo(1).theSubtype = 1
foo(1).ptrSubtype = HEAP_Alloc(SizeOf(bType(foo(1).theSubtype)))
' ...
Sub InsideSub(ByVal Index As Long)
' where index is foo's(Index)
Local data As bType(foo(Index).theSubtype) At foo(Index).ptrSubtype
End Sub