# Variable variable names

**URL:** https://www.finalbuilder.com/forums/t/variable-variable-names/523
**Category:** Discussion
**Created:** [July 12, 2007, 2:21am UTC](https://www.finalbuilder.com/forums/t/variable-variable-names/523 "2007-07-12T02:21:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [July 12, 2007, 2:21am UTC](https://www.finalbuilder.com/forums/t/variable-variable-names/523/1 "2007-07-12T02:21:06Z")

</div>

I've got a number of FinalBuilder variables to control which packages get built in my FinalBuilder script. Their names are like %Build\_connect-core% for the connect-core package, %Build\_connect-admin% for connect-admin, %Build\_mydns-mysql% for the mydns-mysql package, etc.

&nbsp;

I've just written a perl script that gives me a list of packages that need to be built. I'd like to be able to set the Build\_\* variables based on the list of packages, so if I see "connect-core" in the list I want to set %Build\_connect-core% to "True" (they all default to "False"). I was thinking of using a list iterator on the list of packages, putting each package name in turn in a %TEMP% variable, and then somehow setting the appropriate Build\_\* variable based on what is in %TEMP%. I could have a whole bunch of if ... Then actions, one for each possible package, but that's pretty inelegant and makes it a pain when we add more packages. It seems like there ought to be a better way.

&nbsp;

Is there a way to Create a variable name in a variable, and then assign to the name I just created? Basically, if %TEMP% contains "connect-core", I want to assign "%%Build\_%TEMP%%%" to a variable, so its value ends up being "%Build\_connect-core%" and then use that as a reference to the real variable that I want to set to "True". I know I can use that sort of constuct on the "right side" of an assignment, but is there a way to create an lvalue at runtime?

&nbsp;

Or is there a better way? In perl I'd use a hash called %Build and just say $Build{$TEMP} = True. Is there equivalent functionality in Finalbuilder that I've missed?

&nbsp;

Thanks,

&nbsp;&nbsp;&nbsp; Keith

&nbsp;

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [July 12, 2007, 8:25am UTC](https://www.finalbuilder.com/forums/t/variable-variable-names/523/2 "2007-07-12T08:25:46Z")

</div>

Hi Keith,  
  
A while ago I was thinking about how you would put together a project to demonstrate that FinalBuilder is [Turing complete](http://en.wikipedia.org/wiki/Turing-complete). This isn't it, but it reminded me of it.  
(/DorkyComputerScienceTalk)   
  
Anyhow, I've attached a demo project which shows how to set individual variables based on the contents of a list, by using some JScript to edit the VariableName property of a Set Variable action. Normally, you could just set the variable name to be Build\_%ProjectName%. However, in the case of the Set Variable action, variable names are not expanded and the field isn't normally editable, so the JScript is required.

&nbsp;

Another alternative could be to write a simple ActionStudio action in JScript. Please let us know how you go.

&nbsp;

Regards,

Angus

[DynamicVariables.zip](https://www.finalbuilder.com/forums/uploads/default/original/2X/2/2c2fa22a20fa2299393ff891861bfe97f8ddb493.zip) (2.442 KB)

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [July 12, 2007, 8:03am UTC](https://www.finalbuilder.com/forums/t/variable-variable-names/523/3 "2007-07-12T08:03:48Z")

</div>

That works perfectly. Thanks a lot!   
  
 Keith
