Page 1 of 1
[Possible Bug ] Pointers & Structures
Posted: Sun Sep 17, 2017 11:19 am
by Mijikai
Maybe its just me - but there could be a bug !
Testcode (SpiderBasic 2.10 - Demo):
http://forums.spiderbasic.com/viewtopic ... 1282#p4439
Re: [Possible Bug ] Pointers & Structures
Posted: Sun Sep 17, 2017 12:15 pm
by falsam
Confirm
■ This example is correct
Code: Select all
Structure NewDummy
foo1.s
foo2.i
EndStructure
Global *Dummy.NewDummy
*Dummy = AllocateMemory(SizeOf(NewDummy))
*Dummy\foo1 = "hello"
Debug *Dummy\foo1
■ This This example generates a javascript error
Code: Select all
Structure NewDummy
foo1.s
foo2.i
EndStructure
Structure Dummy
Test.NewDummy
EndStructure
Global *Dummy.Dummy
*Dummy = AllocateMemory(SizeOf(Dummy))
*Dummy\Test\foo1 = "Hello" ;console.log say "Cannot set property '_foo1' of undefined"
Debug *Dummy\Test\foo1
Re: [Possible Bug ] Pointers & Structures
Posted: Fri Oct 06, 2017 2:11 pm
by Fred
Unlike PureBasic, you can't use a flat memory buffer and use a structure on it. You need to use AlllocateStructure() if you want dynamically allocated structures
Code: Select all
Structure NewDummy
foo1.s
foo2.i
EndStructure
Structure Dummy
Test.NewDummy
EndStructure
Global *Dummy.Dummy
*Dummy = AllocateStructure(Dummy)
*Dummy\Test\foo1 = "Hello" ;console.log say "Cannot set property '_foo1' of undefined"
Debug *Dummy\Test\foo1