Can I reference the members of a type based upon the order of membership? ie, it's ID.
In other words...
Assume I have a type set up like:
and I want to use a one-size-fits all function when these members are updated, something like :
my point is, right now, I have to do something like:
... which means I duplicate a lot of code. Obviously my real life example is MUCH more complex than this, and while type members give me far more readable code, not being able to reference them by index, I'm duplicating so much code it's getting unwieldy.
So, is there a way to reference the members by ID that I'm missing?
If not, it would be a REALLY welcome addition. I would think they must be internally referenced by an ID of their dimension in an array anyway, no? So it would surely not be too hard to implement?
In other words...
Assume I have a type set up like:
Code (glbasic) Select
GLOBAL allCharacterStats[] AS tCharacterStats
TYPE tCharacterStats
strength
dexterity
constitution
ENDTYPE
and I want to use a one-size-fits all function when these members are updated, something like :
Code (glbasic) Select
FUNCTION userEditsStat:statBeingEdited
IF addButtonPressed = TRUE
inc allCharacterStats[0].statBeingEdited, 1 // no, you cant really do this. that's the point!
ENDIF
ENDFUNCTION
my point is, right now, I have to do something like:
Code (glbasic) Select
SELECT statBeingEdited
CASE 0
inc allCharacterStats[0].strength, 1
CASE 1
inc allCharacterStats[0].dexterity, 1
CASE 2
inc allCharacterStats[0].constitution, 1
ENDSELECT
... which means I duplicate a lot of code. Obviously my real life example is MUCH more complex than this, and while type members give me far more readable code, not being able to reference them by index, I'm duplicating so much code it's getting unwieldy.
So, is there a way to reference the members by ID that I'm missing?
If not, it would be a REALLY welcome addition. I would think they must be internally referenced by an ID of their dimension in an array anyway, no? So it would surely not be too hard to implement?