Create variable name from string?
BlitzMax Forums/BlitzMax Beginners Area/Create variable name from string?
| ||
Hello, ["persisting noob making slow progress towards understanding!"] here again, Is there a way to create a new variable whose name is given by a string? Something like a constructor function for a given variable-type that takes in a "variable_name:string" and declares the variable as such. Thank you in advance with all gratitude and appreciation! |
| ||
Reason is wanting to have an "assets grabber" function that scans through a given folder and creates arrays of images based on the file names. (based on a semi-understood gdc talk) |
| ||
No you cannot create local variables that way. But you can use a TMap. Basically you have a list of keys (lime your variable names) and associate a value (the TImages for example) to it. I use the same approach for a registry-type holding all assets in the game (img font sprites datasets ...) Bye Ron |