Variable name query.... help required please..

Hi there,

I’ve had a search for the answer to this but as yet I’ve not found the answer.

Please can someone tell me if it possible to set a variable to a value and have that value used as a variable name?
The pseudo below probably better highlights what Im trying to do.

set var1 to “xyz”
set (a variable with a name of the value in var1) to 99

The second line would create a variable called ‘xyz’ and set it to 99.

Ultimately I’d like to be able to pass a variable name into a handler and have that used as the name of variable.

Thanks in advance,


The only way I know to do it is with this record hack:

set var to "xyz"
set val to 66
set R to "{" & var & ":" & val & "}"
set myRec to run script R
get myRec's xyz --> 66

You can obviously add other variables to the record this way. I’ve shown only one.

Thanks for your reply and for the code which does exactly what it says on the tin.
I’d found some similar information but didn’t get it to work.

Thanks again. :slight_smile: