Page 1 of 1
Structure reference
Posted: Fri Nov 20, 2020 12:41 pm
by Joubarbe
Following this thread:
viewtopic.php?f=13&t=76294
It would be good to nuance the "not a structure" compiler error:
Code: Select all
Structure _struc
int.i
EndStructure
s = _struc ; *s = @_struc?
Debug _struc ; 0.
Debug s ; 0.
*buffer._struc = AllocateStructure(s) ; ERROR.
Re: Structure reference
Posted: Fri Nov 20, 2020 7:15 pm
by Josh
What are you doing with this command or what do you think this command does?
Sorry, your code is complete nonsense, you should try to understand structures. In any case, you should use EnableExplicit, then you will find your bug somewhere else.
Re: Structure reference
Posted: Sat Nov 21, 2020 7:35 am
by Denis
Joubarbe wrote:Following this thread:
viewtopic.php?f=13&t=76294
It would be good to nuance the "not a structure" compiler error:
Code: Select all
Structure _struc
int.i
EndStructure
s = _struc ; *s = @_struc?
Debug _struc ; 0.
Debug s ; 0.
*buffer._struc = AllocateStructure(s) ; ERROR.
Oh la la la Joubarbe...
The message is correct for me, _struc is the only declared structure in your "code"
What isn't correct is that you write this
s = _struc
Did try to have an equivalent name for _struc?
a variable is not a structure, a variable could be based on a structure.
If you really write code like this, you have to learn to understand what a structure is like Josh wrote.
Re: Structure reference
Posted: Sat Nov 21, 2020 10:15 am
by Joubarbe
Of course this code is wrong, that’s not the point. But yeah forget it, if structure was a class, you would maybe understand the concept of referencing a class, like getClass() in Java. With the Macro system, and how lists work, it would be good to have that kind of thing to make your own list system and not caring about the structure type. I understand structures are a compiler thing, and that would probably require a ton of work to change how things are done under the hood, but something is missing here. If you don’t understand it, too bad (the point was also to read the thread I linked there).
Re: Structure reference
Posted: Sat Nov 21, 2020 11:23 am
by mk-soft
Structure descriptions are not available at runtime.
Only the description of the data to be processed that is required at runtime is available in an internal table (AllocateStructure, FreeStructure). Only offset and type of string, arrays, lists, maps are stored in this table. Not the other data types.
To pass the data type of a structure you have to define it in the structure.
The Windows-API also does this partly in its structures.
Code: Select all
Structure udtData1
Size.i
Type.i
String.s
; ...
EndStructure
Structure udtData1
Size.i
Type.i
iVal1.i
iVal2.i
; ...
EndStructure
Re: Structure reference
Posted: Sat Nov 21, 2020 11:33 am
by Joubarbe
Ok thanks mk-soft, always helpful. Your answer confirms that what I want is not really achievable at the moment. Will code a few more lines instead
