# Dynamic prompt for variable input

**URL:** https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803
**Category:** Discussion
**Created:** [April 9, 2008, 6:15am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803 "2008-04-09T06:15:49Z")
**Posts on this page:** 5
**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: [April 9, 2008, 6:15am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803/1 "2008-04-09T06:15:49Z")

</div>

I would like to dynamically generate variables from a file list, and then prompt a user for the values for those variables. The first part is possible, but is the second?

Essentially- I have this:

Iterate list of server classes  
&nbsp;&nbsp;&nbsp; Get server class name  
&nbsp;&nbsp;&nbsp; Define variable: blnBuild%ServerClass%

This part works. I am having problems with the next part which is dynamically generating the prompt. I'd prefer the prompt for variables (enhanced) because it will hold more than 10 (the limit for the multi question), but don't know how to set the properties.

I almost had it working for the Multi Question, but it did not let me set&nbsp;Action.Answer1FBVariable to the dynamic variable because in order to keep it dynamic, I needed to store the ServerClasses in an array. So, I was using:

Action.Answer1FBVariable = blnBuild & arrSC(1)

It didn't like that.&nbsp;

Is anyone doing anything like this?

---

<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: [April 9, 2008, 7:05am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803/2 "2008-04-09T07:05:48Z")

</div>

Holy cow- I actually got this to work with the MultiQuestion box. Sort of. My problem before was that the names of my server classes were different from my variable names.

I do have one other problem though and that is the multiquestion box only allows 10 questions. I can work out a way to pop up a second box, but&nbsp; I wish I didn't have to. Is there any way I can use the prompt for variables box to do this?

I guess I will also need to change my initial serverclass list with, not the names of the serverclasses, but the names of the variables. Then I can use the the values of the prompts to write a new file with the names of the serverclasses that will actually be in the build.

---

<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: [April 9, 2008, 8:08am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803/3 "2008-04-09T08:08:56Z")

</div>

Sigh. I spoke to soon.

I can not iterate over the list of variables, so what&nbsp; Iwas going to do was to store them all in another variable, and then split them into an array and iterate over the array. The problem is that the script only recognies the name of the variable in the array- not the value of the variable name.

You guys don't have a Variable Set action in a newer version of FB5 do you (I am still on earliest version of it)?

Any help would be appreciated.

This doesn't work:

Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0  
Dim objFSO, oSCFile, arrSC, i, strSC

Set objFSO = CreateObject("Scripting.FileSystemObject")  
Set oSCFile = objFSO.OpenTextFile(strFBTmpDir & "\" & strListBldServerClass , ForWriting, True, TristateFalse)

arrSC = Split(strSCArr,",")

For i = 0 To UBound(arrSC)  
strSC = Mid(arrSC(i),7,Len(arrSC(i))-6)  
&nbsp;&nbsp;&nbsp; If arrSC(i) = True Then  
&nbsp;oSCFile.WriteLine strSC  
&nbsp;&nbsp;&nbsp; End If  
Next

---

<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: [April 10, 2008, 5:02am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803/4 "2008-04-10T05:02:23Z")

</div>

W00T! I was able to get this to work. I think my problem was that I was trying to find a dynamic way of doing what I had previously been doing with the Multi Question. The Multi Question only allows for Boolean variables for input and that was my mistake. I was trying to use a dynamically generated list of these variables to determine if I should run the build on each Server Class. That just won’t work (without a variable set as I talked about in my earlier post).

&nbsp;

In my determination to do this however, I discovered that the Prompt for Variables (Enhanced) action lets you use a check list for input. When I saw that I was like “Hey! I wonder if they let you enter in multiple values delimited with a CrLF, and store it as a pseudo-array?” Bingo!

&nbsp;

I was able to knock this out with 3 actions:

&nbsp;

1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File Contents Iterator Action. This iterates over a file (generated from a previous action) which lists all of the _possible_ server classes I could run the build on.

a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ServerClass variable.

b.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Run Script Action:

If strSCArr = "" Then

&nbsp;&nbsp; strSCArr = ServerClass

Else

&nbsp;&nbsp; strSCArr = strSCArr & vbCrLf & ServerClass

End If 

2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Prompt for Variables (Enhanced).

a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Action: The variable I am prompting for is strSCArr. I have its type defined as “Check List” and its values as %strSCArr% (which was set above)

b.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfterAction Script:   
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0

Dim objFSO, oSCFile, arrSC, i, strSC

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set oSCFile = objFSO.OpenTextFile(strFBTmpDir & "\" & strListBldServerClass , ForWriting, True, TristateFalse)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

arrSC = Split(strSCArr,vbCrLf)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

For i = 0 To UBound(arrSC)

oSCFile.WriteLine arrSC(i)

Next

&nbsp;

The file name stored in strListBldServerClass is the same one that I iterated over in step one.

&nbsp;

So you can see, this actually pretty simple after all if you use the correct variable type.

&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: [April 10, 2008, 7:11am UTC](https://www.finalbuilder.com/forums/t/dynamic-prompt-for-variable-input/803/5 "2008-04-10T07:11:34Z")

</div>

Hi Owen,   
  
Looks good, glad you got it working. It's good to see that you found a solution which did not require the use of the Define Variable Action, we generally discourage use of this action.   
  
Regards,   
  
Angus
