Have a look at this code fragment:
Code: Select all
type flddef field = 1
name as string * 16
namelen as ubyte
type as ubyte
size as ushort
end type
print sizeof(flddef)
But there's more:
I have a string whose content ("outstr", whose length is 100 bytes) is what should be passed into flddef with these lines of code:
Code: Select all
recdef = allocate(5 * sizeof(flddef))
for i = 0 to 4
memcpy(@recdef[i], sadd(outstr) + i * 20, sizeof(flddef))
next
Code: Select all
for i = 0 to flds * sizeof(flddef) - 1
ch = *(cast(ubyte ptr, recdef) + i)
print hex(ch, 2); " ";
linlen += 1
if linlen = sizeof(flddef) then
linlen = 0
print
endif
next
print
Code: Select all
41 4C 50 48 41 30 30 30 30 30 30 30 30 30 30 31 D0 10 0A 00 42
42 45 54 41 30 30 30 30 30 30 30 30 30 30 30 32 10 02 02 00 47
47 41 4D 4D 41 30 30 30 30 30 30 30 30 30 30 33 90 03 04 00 44
44 45 4C 54 41 30 30 30 30 30 30 30 30 30 30 34 10 08 04 00 45
45 50 53 49 4C 4F 4E 30 30 30 30 30 30 30 30 35 10 10 14 00 00
Code: Select all
for i = 0 to flds - 1
print recdef[i].name; " "; recdef[i].namelen; " "; recdef[i].type; " "; recdef[i].size
next
Code: Select all
ALPHA00000000001 208 16 10
BETA000000000002 16 2 2
GAMMA00000000003 144 3 4
DELTA00000000004 16 8 4
EPSILON000000005 16 16 20
Code: Select all
ALPHA00000000001 16 10 16896
BETA000000000002 2 2 18176
GAMMA00000000003 3 4 17408
DELTA00000000004 8 4 17664
EPSILON000000005 16 20 0
I'm considering getting help from a good psychiatrist but thought maybe I'm not the problem...