Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-27-2003, 01:41 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
Using VBScript arrays

I want to use VBT to automate software deployments at the office. There are roughly 10 servers I deploy to and they’re split up into two batches. I’ve created arrays to access each server by name and I’d like to access the array variable in VBT. My project in its simple form looks like this:



Foundry (Group)
Initialize Batch1 Variables (VBScript)
Run Loop (Group
Do Stuff Here
Do More Stuff Here
Increment Counter

So the Foundry group initializes some variables and defines an array. The initialize script looks like this.

Dim Batch1(5)
Batch1(0) = "order1"
Batch1(1) = "order2"
Batch1(2) = "product5"
Batch1(3) = "product6"
Batch1(4) = "orderadmin9"

Application.Macros(vbldTemporary).Add "SERVER_NUMBER", "0"
'Application.Macros(vbldTemporary).Add "SERVER_ARRAY", Batch1
Application.Macros(vbldTemporary).Add "TOTAL_BATCH1", UBound(Batch1)

SERVER_NUMBER is a counter that simply defines how many iterations to run. I define it as 0 here because the first element in the array is always 0.
SERVER_ARRAY, which is commented out is where I’d like to pass the array from the VBScript to VisualBuildTool.
TOTAL_BATCH1 is just the number of the highest element in the array.

What I want to happen is in the loop, certain actions will be performed on %SERVER_ARRAY%(%SERVER_NUMBER%)

This should equate to Batch1(0)…(Batch1(4)

But I get errors when I try to move the array over into VBT.

Any help is appreciated.

Last edited by gdanko; 05-27-2003 at 02:51 PM.
Reply With Quote
  #2  
Old 05-27-2003, 03:56 PM
pjaquiery pjaquiery is online now
Registered User
 
Join Date: 01-20-2003
Location: Dunedin, New Zealand
Posts: 114
I think you need to turn the problem inside out. Store the array as a VBP macro and use a bit of script to extract the elements one at a time, perhaps to another VBP macro.

In similar situations I use strings of comma delimited elements as an "array" and have a script function that pops the first element off the list.
Reply With Quote
  #3  
Old 05-27-2003, 04:46 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
Got any examples on how to store the array as a VBP array? Until hearing from you I will experiment.
Reply With Quote
  #4  
Old 05-27-2003, 04:54 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Script variables do not persist outside of a Run Script step. One way to accomplish this would be to put your generic steps into a subroutine (on the Subroutine Steps or Global Subroutine Steps tab) and add one Subroutine Call step for each server in the Project Steps, passing the dynamic values for the subroutine on the Parameters tab. See the Advanced.bld or VisBuildPro.bld samples.

If you wanted to read the list of servers more dynamically (for instance, from a file), the Misc.bld sample ('Repeat for file contents' group) demonstrates how you can load a list of values into a temporary macro, and then loop over the macro, extracting each filename (using the vbld_AddDelimValue/vbld_NextDelimValue system script functions) and processing each one.
Reply With Quote
  #5  
Old 05-27-2003, 04:55 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
Every other variable comes through except the one where I try to pass the array. It errors out because I am trying to pass an array. If I assign any value, it works. I can send you a copy of the project if that helps.
Reply With Quote
  #6  
Old 05-27-2003, 05:05 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
I don't want to be able to access the VBS array Batch1() directly.

In this example I was able to assign the results of the VBS expression UBound(Batch1) to the VBP TOTAL_BATCH1. This works.

Application.Macros(vbldTemporary).Add "TOTAL_BATCH1", UBound(Batch1)

In VBS I can do something like this:

dim Array1(3)
Array1(0) = "Blah"
Array1(1) = "Foo"
Array1(2) = "Fubar"

ABC123 = Array1

MsgBox ABC123(2)

This code will give me a msgbox with "Fubar" in it. I am saying, this array in VBS is equal to this array in VBS.

I was able to pass an VBS variable to a VBP variable. I want to be able to pass my VBS array to VBP so it can be used.

The PDF documentation isn't of much help here.


Last edited by gdanko; 05-27-2003 at 05:37 PM.
Reply With Quote
  #7  
Old 05-28-2003, 03:24 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
problem solved
Reply With Quote
  #8  
Old 05-28-2003, 03:46 PM
pjaquiery pjaquiery is online now
Registered User
 
Join Date: 01-20-2003
Location: Dunedin, New Zealand
Posts: 114
Out of interest, and for the edification of others who may have a similar problem, how do you solve it?
Reply With Quote
  #9  
Old 05-28-2003, 03:48 PM
gdanko gdanko is online now
Registered User
 
Join Date: 05-27-2003
Posts: 18
The first step of my loop determines the server name this way.

Dim Batch1(3)
Batch1(0) = "WWW6"
Batch1(1) = "WWW7"
Batch1(2) = "WWW8"

Application.Macros(vbldTemporary).Add "SERVER", Batch1(%COUNTER%)

The counter is increased with each iteration, so the current server name is set approriately.

I am now configuring it to read an .ini file for the number of servers and server names.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 01:44 PM.


Copyright © 1999-2023 Kinook Software, Inc.