Structure GENERALINPUT
dwType .l
xi.b(23)
EndStructure
When i enter this i get
---------------------------
PureBasic
---------------------------
Line 3: Garbage at the end of the line.
---------------------------
OK
---------------------------
Please tell me why
Byte Array inside Structure Error
Re: Byte Array inside Structure Error
Add... Array xi.b(23)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Byte Array inside Structure Error
Code: Select all
Structure GENERALINPUT
dwType .l
xi.b[24]
EndStructure
Code: Select all
Structure GENERALINPUT
dwType .l
Array xi.b(23)
EndStructure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Byte Array inside Structure Error
wow thank you didnt know PB has Array as keyword 

Re: Byte Array inside Structure Error
Differences between the two ways of defining arrays in Structures:
The first is an static array, which you can not resize! The byte array is part of the structure (see size of structure)
The second one is an dynamic array, which you can resize. The structure only contains an pointer to the array!
Maybe others can add more information and differences!
cu,
guido
Code: Select all
Structure GENERALINPUT1
dwType .l
xi.b[24]
EndStructure
Structure GENERALINPUT2
dwType .l
Array xi.b(23)
EndStructure
Debug SizeOf(GENERALINPUT1)
Debug SizeOf(GENERALINPUT2)
The second one is an dynamic array, which you can resize. The structure only contains an pointer to the array!
Maybe others can add more information and differences!
cu,
guido
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
PB Last Final / Last Beta Testing
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Byte Array inside Structure Error
Not exactly true. If you put zero in the brackets you have a completely dynamic array, any size you like, which can be accessed by index as long as the memory it points to is valid. A small example:The first is an static array, which you can not resize! The byte array is part of the structure (see size of structure)
Code: Select all
Structure stuff
char.b[0]
EndStructure
a$ = "start"+Space(50000)+"end"
*char.stuff = AllocateMemory(50009)
PokeS(*char, a$)
Debug Chr(*char\char[50005])+Chr(*char\char[50006])+Chr(*char\char[50007])
BERESHEIT