Page 1 of 1
[Done] 4.5 b2 x86 Structured pointer access to map fails
Posted: Fri Apr 02, 2010 5:23 pm
by netmaestro
Code: Select all
Structure zoo
Map cat.l()
EndStructure
*buf.zoo = AllocateMemory(SizeOf(zoo))
*buf\cat("felix") = 36
Debug *buf\cat("felix")
A variable of type zoo works without error, however the structured memory block causes an IMA.
Re: Structured pointer access to map fails
Posted: Fri Apr 02, 2010 5:27 pm
by ts-soft
You have to Initialisize the structure:
Code: Select all
Structure zoo
Map cat.l()
EndStructure
*buf.zoo = AllocateMemory(SizeOf(zoo))
InitializeStructure(*buf, zoo)
*buf\cat("felix") = 36
Debug *buf\cat("felix")
greetings
Thomas
Re: Structured pointer access to map fails
Posted: Fri Apr 02, 2010 5:29 pm
by netmaestro
Thanks Thomas - so that's what InitializeStructure is for. The docs don't properly explain that.
Re: [Done] 4.5 b2 x86 Structured pointer access to map fails
Posted: Fri Apr 02, 2010 5:34 pm
by ts-soft
I have asked in the German forum for this function and freak has explained the function to me

Re: [Done] 4.5 b2 x86 Structured pointer access to map fails
Posted: Fri Apr 02, 2010 6:46 pm
by milan1612
makes sense, thanks for the explanation ts

Re: [Done] 4.5 b2 x86 Structured pointer access to map fails
Posted: Fri Apr 02, 2010 8:19 pm
by gnasen
InitializeStructure() is a very powerful command you can use for example to create trees (which are some lists in lists in lists...). Its some kind of tricky, but very powerful, example:
http://www.purebasic.fr/german/viewtopi ... =8&t=22177