[Gambas-user] A variable in a variable

Pablo Vera pvera at ...729...
Thu May 11 00:28:01 CEST 2006


You could do something like this:

--------------------------------------------------

DIM var AS String
DIM bar AS String

DIM Context AS NEW Collection

DIM S AS String

   var = "some value"
   bar = "other value"

   Context["var"] = var
   Context["bar"] = bar

   S = "v"
   Result = Eval(S & "ar", Context)

   S = "b"
   Result = Eval(S & "ar", Context)

--------------------------------------------------

Saludos,
Pablo Vera

Arno Nuyts wrote:
> Hello,
> I'm a new user of Gambas and just discovering it's language. I'm doing a 
> simple project but came to my first problem that I couldn't solve with 
> the documentation in the wiki.
> I want to include a variable in the name of a variable. I've searched 
> for it in a forum and there it was said it couldn't be done. Is this 
> true and if so, are there work arounds?
> In PHP it's written like this
> 
>     $var = "Variable"
>     $in = "ar"
>     if($v$in == Variable) {
>        echo"expected";
>      }
> 
> Greetings,
> 
> Arno
> 




More information about the User mailing list