Maybe its just me - but there could be a bug !
Testcode (SpiderBasic 2.10 - Demo):
http://forums.spiderbasic.com/viewtopic ... 1282#p4439
[Possible Bug ] Pointers & Structures
Re: [Possible Bug ] Pointers & Structures
Confirm
■ This example is correct
■ This This example generates a javascript error
■ 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
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
➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
➽ http://falsam.com
Sorry for my poor english
Re: [Possible Bug ] Pointers & Structures
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