Closed Awuwunya closed 3 years ago
It can be done in the following way:
; store:
ix := "0"
variable{ix} := 1234
; load to variable
ix := "0"
temp := variable{ix}
message "variable\{ix} is \{temp}"
If you try with integer ix, it will fail; I guess I should make AS just stringify the integer in this case, as it is an arbitrary error.
I remember this back from the day of working on AMPS. I used to not have an external tool to deal with music or SFX, I actually sort of hackily constructured arrays. Like for example, variable0, variable1, variable2, etc...
I tried to make this happen in AS, but despite my best efforts, it would never work out like I expected at all. I'm not even aware if this is possible in the first place, but making it possible would allow for some... "unconventional" programming features to exist. Specifically, my problem was that I could not figure out how to fetch values, so it was difficult to tell if I was even storing values correctly in the first place. I would never get out anything that made sense.
ASM68K, oddly enough, allows this to work despite it probably not being intentional:
Since assemblers don't really support arrays, you can't do some things so easily, and this is one way to work around it, but I was never able to figure out how to make AS do the equivalent, sadly.