Relative value of variable

Hi,

I have problem in my script. Script calculate values which I would like to use as variable names to access that value.

set x to “One” as string

set y to “x” as string

set gg to (get y) – This give “x” but I need “One”

Please help me to solve this problem.

Best regards,

Normunds

Maybe this will work for your purposes:

set x to "One" as string

set y to "x" as string

set gg to (get y) -- This give "x" but I need "One"
--display alert (gg as text) as informational -- "x"
set gg to getMyNamedVar(y)
display alert (gg as text) as informational -- "One"

to getMyNamedVar(varName)
	run script "on run {obj}" & return & "obj's " & varName & return & "end" with parameters {me}
end getMyNamedVar

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi,

the name of the variable and its value are different things

set x to "One" -- a literal string IS a string
copy x to y
set gg to y -- "One"

Note: if you have a list or an other reference, set “copies” the reference, not the value, e.g.

set x to {"One", "Two"}
set y to x
set item 2 of y to "Three"
x -- {"One", "Three"}

instead of copy, which copies the value

set x to {"One", "Two"}
copy x to y
set item 2 of y to "Three"
x -- {"One", "Two"}

Big Thank’s Chrys!

It really work!!!

Normunds