Hi Folks,
I'm writing a program where I'me working with several random access files (a mini database using Btree type keys).
What I'd like to do is create a generic UDT for most of what I need (filename, filenumber, etc) and then have another UDT for the specific data that would go into each one.
Ideally I would have a generic pointer in the "meta' UDT where I could store the address of the "data" udt. I know that I can do this by having a dword store the actual value and use a union with "options" for every "data" udt I need.
But that's a PITA.
If I remember my C this would be typecasting the pointer (been about 10 years...)
I'd like it to look like this:
Is that do-able? Or am I missing something?
JS
I'm writing a program where I'me working with several random access files (a mini database using Btree type keys).
What I'd like to do is create a generic UDT for most of what I need (filename, filenumber, etc) and then have another UDT for the specific data that would go into each one.
Ideally I would have a generic pointer in the "meta' UDT where I could store the address of the "data" udt. I know that I can do this by having a dword store the actual value and use a union with "options" for every "data" udt I need.
But that's a PITA.
If I remember my C this would be typecasting the pointer (been about 10 years...)
I'd like it to look like this:
Code:
Type data01 a as long b as string * 10 End Type Type data02 c as quad d as string * 30 End Type Type meta filename as string filenumber as long GPTR as generic pointer End Type dim meta01 as meta dim meta02 as meta dim d1 as data01 dim d2 as data02 meta01.filename="file01.dat" meta01.filenumber=freefile meta01.GPTR=varptr(d1) meta02.filename="file02.dat" meta02.filenumber=freefile meta02.GPTR=varptr(d2)
JS
Comment