Dynamic prompt for variable input

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
    Get server class name
    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 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. 

Is anyone doing anything like this?

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  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.

Sigh. I spoke to soon.

I can not iterate over the list of variables, so what  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)
    If arrSC(i) = True Then
 oSCFile.WriteLine strSC
    End If
Next

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).
 
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!
 
I was able to knock this out with 3 actions:
 
1.       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.       Set ServerClass variable.
b.       Run Script Action:
If strSCArr = "" Then
   strSCArr = ServerClass
Else
   strSCArr = strSCArr & vbCrLf & ServerClass
End If
2.       Prompt for Variables (Enhanced).
a.       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.       AfterAction Script:
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,vbCrLf)
       
For i = 0 To UBound(arrSC)
oSCFile.WriteLine arrSC(i)
Next
 
The file name stored in strListBldServerClass is the same one that I iterated over in step one.
 
So you can see, this actually pretty simple after all if you use the correct variable type.

 

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