RestoreData - 'string' label ?

BlitzMax Forums/BlitzMax Programming/RestoreData - 'string' label ?

LamptonWorm(Posted 2013) [#1]
Hi all,

I have a function that calls RestoreData and at the moment it's hard-wided for example,

If blah="blah1" Then RestoreData blah1
If blah="blah2" Then RestoreData blah2


Is there a way to simply this to something like..

RestoreData blah


I can't work out if I can cast blah (string) to label :) ideas welcome!

Cheers,
LW.


Yasha(Posted 2013) [#2]
You're looking for functionality more advanced than the RestoreData command was designed to handle (it's really a very archaic mechanism intended for backwards-compatibility with older BASICs).

If you really want the data to be a part of your program binary, try IncBin instead: it lets you read from the included data as though reading from a file, and that means you can open streams to the data using string paths (because it's the same as looking for a file).

Alternatively, if you need this to be dynamic, why not just let the data itself be dynamic and use files for real? That'll make it much easier to swap in new content, which will help you to design a more generic and clean system.


LamptonWorm(Posted 2013) [#3]
Thanks Yasha, I will look into moving my data into files, good call.

Cheers,
LW.