Just starting out? Need help? Post your questions and find answers here.
netmaestro
PureBasic Bullfrog
Posts: 8451 Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada
Post
by netmaestro » Fri Apr 02, 2010 5:23 pm
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
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Fri Apr 02, 2010 5:27 pm
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
netmaestro
PureBasic Bullfrog
Posts: 8451 Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada
Post
by netmaestro » Fri Apr 02, 2010 5:29 pm
Thanks Thomas - so that's what InitializeStructure is for. The docs don't properly explain that.
BERESHEIT
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Fri Apr 02, 2010 5:34 pm
I have asked in the German forum for this function and freak has explained the function to me
milan1612
Addict
Posts: 894 Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:
Post
by milan1612 » Fri Apr 02, 2010 6:46 pm
makes sense, thanks for the explanation ts
Windows 7 & PureBasic 4.4