ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: slyone on February 18, 2012, 06:41:27 AM

Title: Problems creating a dynamic variable
Post by: slyone on February 18, 2012, 06:41:27 AM
I'm trying to create a variable name dynamically.  The test code I am using is below:

Code: [Select]
set %var1 10
set %var2 string

set % , %var1 , %var2 XXXXX

display % , %var1 , %var2
halt

I want the variable to be "%10string" and to have a value of XXXXX.  But when I use the display command it shows the string %10string rather than the value XXXXX. 

Can anyone help?
Title: Re: Problems creating a dynamic variable
Post by: TrailMyx on February 18, 2012, 09:27:34 AM
You have to use a combination of the dot operator and the concatenation operator.

Code: [Select]
set %var1 10
set %var2 string

set % . %var1 , %var2 Worked

display %10string
halt
Title: Re: Problems creating a dynamic variable
Post by: manwinc on February 18, 2012, 09:41:26 AM
For what you are doing, you would need to use an intermediate step in order to Extract the Data from your Dynamic Variable.

Code: [Select]
set %Var1 10
set %Var2 String
set %Temp %Var1 , %Var2
set % , %Temp Worked
display % . %Temp
Halt

The Easiest way to get around this is just to Bypass the Var2.

Code: [Select]
set %Var1 10
set %String , %Var1 Worked
Display %String . %Var1
halt

Once you get the Hang of it, its not Tooo Bad.

Title: Re: Problems creating a dynamic variable
Post by: slyone on February 18, 2012, 10:42:04 AM
You have to use a combination of the dot operator and the concatenation operator.

Code: [Select]
set %var1 10
set %var2 string

set % . %var1 , %var2 Worked

display %10string
halt

For what you are doing, you would need to use an intermediate step in order to Extract the Data from your Dynamic Variable.

Code: [Select]
set %Var1 10
set %Var2 String
set %Temp %Var1 , %Var2
set % , %Temp Worked
display % . %Temp
Halt

The Easiest way to get around this is just to Bypass the Var2.

Code: [Select]
set %Var1 10
set %String , %Var1 Worked
Display %String . %Var1
halt

Once you get the Hang of it, its not Tooo Bad.



Thank you!!