Re: mixedlib.e: nested structs=?windows-1251?Q?=3f?=
- Posted by Bernie Ryan <xotron at BUFFNET.NET> May 27, 2000
- 449 views
On Sat, 27 May 2000 23:59:15 +0400, CenSe <cense at MAIL.RU> wrote: > Is it possible to nest a struct created by mixedlib.e inside another struct >* TEST PSEUDO CODE * > >atom nested, ptr >nested = struc( "foo : byte : 1", HIGH ) >pt = struc( "bar : struct : length( nested ) ", HIGH ) > >Set( ptr, "bar", nested ) CenSe: -- you can define a structure that can contains other structures like this -- use the same techniques as the last post. pointer nested, ptr -- what you want to nest nested = struc( "foo : byte : 1 ", HIGH ) -- allocate the place where you are going to nest ptr = struc( "bar : byte : sizeof( nested ) ", HIGH ) -- Now you can set values in nested with Sets() function -- then copy the structure in to the ptr structure like this -- loc() function returns the offset of structure mem_copy( loc(ptr,"bar"), nested, sizeof(nested) ) -- To get data out of the structure copy the structure out to nested -- mem_copy( nested, loc(ptr,"bar"), sizeof(nested) ) -- -- then use the Gets() function to access the data from the nested structure. I hope that helps Bernie