Search the Community
Showing results for tags 'expandvarstrings'.
-
Hello, I'd like to be able to create variables 'on the fly' by reading in some data from an SQLite database. Using this data i'd like to create variables. The data would be separated by colons (":")...'colon delimited'. I would perform a 'StringSplit' on the data to create arrays holding each colon separated value. Ideally I could then use these strings to create variables from them...possible? I know it cannot be done just piecing a string together such as "var = "$_" & 'some string'"... I think it might work using the 'Assign' command...and there is an 'Opt' option to 'ExpandVarStrings' which seems to indicate it is possible to include a "$" within a string...however the documentation is a bit spotty on that. Can anybody confirm that these might be the best practices to create variables dynamically? ...Perhaps there is another method I'm not thinking of...? I thank you in advance. Regards.
-
The following code: Opt("ExpandVarStrings", True) $string1 = "something" $string2 = "another thing" $try = "this" $stringToUse="string1" ; Test bit 1 ConsoleWrite("=====" & @CRLF) ConsoleWrite("Test: '$try$', '$" & $stringToUse & "$'@CRLF@") ConsoleWrite("-----" & @CRLF) ; Test bit 2 ConsoleWrite("=====" & @CRLF) ConsoleWrite("Test: '$string2$'@CRLF@") ConsoleWrite("-----" & @CRLF) ... produces: Main question: can I read the variable to read from from a variable, like I tried in "Test bit 1"? (If not, then why?) Second question: if I cannot and if it is because the string expansion is done at "compile time" or something, why does it break the expansion of the "@CRLF@" after the concatenated string as well (but not before - the $try$ is expanded just fine), but then still just outputs a string and doesn't throw any errors? I don't have a particular thing I'm trying to accomplish; another question about language files just made me remember that I used this option long ago and it helped me greatly for that purpose. This to say that I don't need other approaches. I'm just playing around - I probably wouldn't use the ExpandVarStrings for anything serious at this point anyway