1. mixedlib.e: nested structs=?windows-1251?Q?=3f?=
- Posted by CenSe <cense at MAIL.RU>
May 27, 2000
-
Last edited May 28, 2000
Hello Bernie or anyone that is familiar with his mixedlib.e,
Is it possible to nest a struct created by mixedlib.e inside another struct
created the same way? as in on struct is a member of another struct. If this
is possible, how can it be done?
something like this:
* TEST PSEUDO CODE *
atom nested, ptr
nested = struc( "foo : byte : 1", HIGH )
pt = struc( "bar : struct : length( nested ) ", HIGH )
Set( ptr, "bar", nested )
????
* END TEST PSEUDO CODE *
is this in anyway possible or am i just dreaming?
thanks in advance.
CenSe,
a member of the
ak-software
development team
http://ak-software.virtualave.net/
2. Re: mixedlib.e: nested structs=?windows-1251?Q?=3f?=
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