[Done] 4.5 b2 x86 Structured pointer access to map fails

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

[Done] 4.5 b2 x86 Structured pointer access to map fails

Post 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.
Last edited by netmaestro on Fri Apr 02, 2010 5:31 pm, edited 1 time in total.
BERESHEIT
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Structured pointer access to map fails

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Structured pointer access to map fails

Post by netmaestro »

Thanks Thomas - so that's what InitializeStructure is for. The docs don't properly explain that.
BERESHEIT
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [Done] 4.5 b2 x86 Structured pointer access to map fails

Post by ts-soft »

I have asked in the German forum for this function and freak has explained the function to me :wink:
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Re: [Done] 4.5 b2 x86 Structured pointer access to map fails

Post by milan1612 »

makes sense, thanks for the explanation ts :P
Windows 7 & PureBasic 4.4
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Re: [Done] 4.5 b2 x86 Structured pointer access to map fails

Post 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
pb 5.11
Post Reply