Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] User Tips, Tricks and Samples
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
  #1  
Old 04-14-2010, 10:10 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Modify scripts with another script

I am working on a script to modify a batch of scripts in a folder, I have a script action as follows:

'Create Sub Call
Option Explicit

Dim objApp, objStep, objMacro

' create VisBuildPro app object
Set objApp = CreateObject("VisBuildSvr7.Application")
objApp.Project.Load "%PROCFILES_FULLPATH%"

Set objStep = objApp.Project.Steps(vbldStepMain).Add("Subroutine Call", 6)
objStep.Name = "Get Version History List"
objStep.Indent = 2
objStep.Property("SubName") = "SUB Get Version History List"
objStep.Property("Expand") = -1

objApp.Project.Save


When I run the script it modify's creates the following in a script file:

<step action='Subroutine Call'>
<Expand type='2'>-1</Expand>
<SubName>SUB Get Version History List</SubName>
<indent type='3'>2</indent>
<name>Get Version History List</name>
</step>


If I create the same step manually it looks like this:

<step action='Subroutine Call'>
<Expand type='11'>-1</Expand>
<SubName>SUB Get Version History List</SubName>
<indent type='3'>2</indent>
<name>Get Version History List</name>
</step>


The main difference between the two is teh type value of the Expand in one its 11 and when I create it through script its a value of 2

My question is what does the value of type represent and how do I change it? Also what is the type value in indent property represent?
Reply With Quote
  #2  
Old 04-14-2010, 10:58 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
The type indicates the data type of the property value (http://msdn.microsoft.com/en-us/library/ms221170.aspx). 2 = VT_I2 (2-byte integer), 3 = VT_I4 (4-byte integer), 11 = VT_BOOL (boolean)

Use
Code:
objStep.Property("Expand") = True
to assign a boolean true value to the property (Visual Build will also convert the value to the required type if possible).
Reply With Quote
  #3  
Old 04-14-2010, 11:05 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Talking

Thanks it works perfectly!!!
Reply With Quote
  #4  
Old 04-28-2010, 09:11 AM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
I was able to get the above to work, but I am having some difficualty finding any documentation on how to add and edit exisiting Parameters for a sub call.

Through the object model I want to search for a specific subcall which I am able to do. Now I want to modify and add some Parameters to the call and save it back out. I am not sure what properties or methodes to use to access these types.
Reply With Quote
  #5  
Old 04-28-2010, 09:42 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
For array properties (grid fields), the returned value is a variant array with a lower bound of 0.
http://www.kinook.com/VisBuildPro/Ma...typroperty.htm

In VBScript, to assign array properties, use something like:

Code:
objStep.Property("Parameters") = Array("Name1", "Name2", "Name3")
objStep.Property("ParamValues") = Array("val1", "val2", "val3")
Reply With Quote
  #6  
Old 04-28-2010, 02:00 PM
HippyCraig HippyCraig is offline
Registered User
 
Join Date: 07-27-2006
Location: Philly
Posts: 211
Thanks I was able to get it to work. Just to explain what I was doing see code snipit below. This seems to work but if there is better way I am open to sugestions.



Option Explicit

Dim objApp, objStep, objStepToMod, iCurrentIndexID, strSetupProject, arrParameters, arrParamValues, iCount
Dim strProjectFile, strComments, strInstallAllUsers, strProductName, strTitle, strManufacturer, strAuthor, strReleseMSIName, strVirtualDir

Set objApp = CreateObject("VisBuildSvr7.Application")
objApp.Project.Load "%PROCFILES_FULLPATH%"

'Set Find Step
For Each objStep in objApp.Project.Steps(vbldStepMain)
If objStep.Property("SubName") = "SUB Modify Setup Project" Then
iCurrentIndexID = objStep.Index

arrParameters = objStep.Property("Parameters")
arrParamValues = objStep.Property("ParamValues")

'Read in Values
For iCount = 0 to UBound(arrParameters)
If arrParameters(iCount) = "TMP_PROJECT_FILE" Then strProjectFile = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_COMMENTS" Then strComments = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_INSTALL_ALL_USERS" Then strInstallAllUsers = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_PRODUCT_NAME" Then strProductName = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_TITLE" Then strTitle = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_MANUFACTURER" Then strManufacturer = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_AUTHOR" Then strAuthor = arrParamValues(iCount)
If arrParameters(iCount) = "TMP_RELEASE_MSI_NAME" Then strReleseMSIName = arrParamValues(iCount)
Next

'Find Virtual Directory
'This code would open a file found in one of the properties and find a Virtual Directory in the setup and populate
'populate that new value in the sub call
'strSetupProject = vbld_GetFileContents(objApp.ExpandMacros(strProjec tFile))

'Reasign Values
objStep.Property("Parameters") = Array("TMP_PROJECT_FILE", "TMP_COMMENTS", "TMP_INSTALL_ALL_USERS", "TMP_PRODUCT_NAME", "TMP_TITLE", "TMP_MANUFACTURER", "TMP_AUTHOR", "TMP_RELEASE_MSI_NAME", "TMP_VIRTUAL_DIR")
objStep.Property("ParamValues") = Array(strProjectFile, strComments, strInstallAllUsers, strProductName, strTitle, strManufacturer, strAuthor, strReleseMSIName, strVirtualDir)

End If
Next


Builder.LogMessage("Added New Virtual Directory '" & strVirtualDir & "' to Sub Call")
objApp.Project.Save
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 07:32 PM.


Copyright © 1999-2023 Kinook Software, Inc.