STARGÅTE wrote:-1
[n] is for static array like:
Code: Select all
Structure Example
StructureUnion
String.s{36}
Month.s{3}[12]
EndStructureUnion
EndStructure
Define Example.Example\String = "JanFebMarAprMayJunJuiAugSepOctNovDec"
Debug Example\Month[0]
Debug Example\Month[3]
Debug Example\Month[11]
charvista was asking for using brackets [ ] for PB standard type .s, so it would not affect your code.
Code: Select all
Debug Example\String[0,3] ; would return "Jan"
It is possible to do what she requested in other languages by overloading operators [].
The difference is where it is used, If used on the left hand side, it is a target of an expression.
If used on the right hand side, it is an expression like Mid().
Code: Select all
s.s = Example\String[0,3] ; would return "Jan"
Example\String[0,3] = "XYZ" ; would replace "Jan" with "XYZ"
In your seconds example:
Code: Select all
s.s = Example\Month[1][0,10] ; would return "Feb"
Example\Month[1][0,3] = "XYZ" ; would replace "Feb" with "XYZ"
Good idea. Maybe just too advanced and complicated for PureBasic.