|
Yanuth Newbie
Joined: 22 Feb 2006 Posts: 9
|
Posted: Fri Feb 24, 2006 5:09 am
Multi Word Variable Accessing... |
While trying to find a simple solution for a different problem I ran into this little puzzle (for me anyway)...
I can create a variable that has more than 1 word for its name, with a value... By doing at the prompt simply:
#var {hello you} 10
Which then gives me a variable with the name 'hello you' and the value 10... But how do I access it and read the value back from it?
Simply typing:
#show @hello you
gives 'you' as a result, as does #show @{hello you}, and any other version I have so far came up with...
It annoys me mostly that I feel the solution has to be dead simple somehow...
P.S. I CAN do #var {hello you}, which then gives me a nice msg about the variable and its value, but that's not the kind of accessing I had in mind of course :P I need to be able to increment the number, or display it alone, or compare it to a different variable/number :) |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Feb 24, 2006 10:06 am |
Variables are not supposed to have spaces in thier names. There are actually a large number of excluded characters, but a number of commands preform no checking when creating the variable. This is done as a feature to help users find bad indirect variable references.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Vorax Apprentice
Joined: 29 Jun 2001 Posts: 198 Location: USA
|
Posted: Sat Feb 25, 2006 11:40 am |
You could replace the spaces in your multi-word variables with underscores which would then allow you to access the variable's value.
Code: |
#ALIAS makevar {#VARIABLE %replace( %1, " ", "_") {%2}} |
Usage:
makevar {hello you} 10
Will create the variable "hello_you" with a value of "10".
You can, of course, replace the alias name 'makevar' with whatever will be easier for you to use. |
|
|
|
|
|