Kinook Software Forum

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

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-19-2012, 10:16 AM
cholzwarth cholzwarth is online now
Registered User
 
Join Date: 03-19-2010
Posts: 5
Returning variable from PowerShell subroutine

I have a PowerShell subroutine that does string manipulations. I can get the resulting string that I want. Is there a way to set the result to a variable that Visual Build Pro will see when the subrouting exits?
Reply With Quote
  #2  
Old 03-19-2012, 11:10 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
One way to return values from PowerShell to VBP is via global macros.
http://www.kinook.com/VisBuildPro/Ma...ershelltab.htm
Reply With Quote
  #3  
Old 03-19-2012, 12:30 PM
cholzwarth cholzwarth is online now
Registered User
 
Join Date: 03-19-2010
Posts: 5
Doesn't work

What I get when I try this is:

3/19/2012 1:24:58 PM: Building project step 5 - Subroutine Call...
3/19/2012 1:24:58 PM: Building subroutine step 1 - PS_to_VB_Macro...
3/19/2012 1:24:59 PM: Building subroutine step 2 - PowerShell...
New-Object : Cannot load COM type VisBuildSvr.Application.
At C:\DOCUME~1\CM-PAY~1\LOCALS~1\Temp\VisBAD.tmp.ps1:3 char:18
+ $app = New-Object <<<< -com VisBuildSvr.Application
You cannot call a method on a null-valued expression.
At C:\DOCUME~1\CM-PAY~1\LOCALS~1\Temp\VisBAD.tmp.ps1:6 char:22
+ $global = $app.Macros( <<<< 2)
You cannot call a method on a null-valued expression.
At C:\DOCUME~1\CM-PAY~1\LOCALS~1\Temp\VisBAD.tmp.ps1:12 char:12
+ $global.Add( <<<< "XYZ", "val1`tval2")
You cannot call a method on a null-valued expression.
At C:\DOCUME~1\CM-PAY~1\LOCALS~1\Temp\VisBAD.tmp.ps1:15 char:13
+ $global.Save( <<<< )
3/19/2012 1:25:02 PM: Build successfully completed (elapsed = 00:00:04).

The script:

# create app object

$app = New-Object -com VisBuildSvr.Application
# retrieve global macros

$global = $app.Macros(2)

# WRITE A VALUE TO Visual Build

# create/update macro with two values delimited by tab

$global.Add("XYZ", "val1`tval2")
# save changes to global macros (accessible in the following steps in Visual Build)

$global.Save()
Reply With Quote
  #4  
Old 03-19-2012, 01:38 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
If you're running v7, you'll need to use VisBuildSvr7.Application (version-independent ProgID is new in v8).
Reply With Quote
  #5  
Old 03-19-2012, 02:08 PM
cholzwarth cholzwarth is online now
Registered User
 
Join Date: 03-19-2010
Posts: 5
Is there a 32 bit version

The system I am using for builds is a 32 bit system. Is there a 32 bit version of Visual Build Pro 8?

I did get my kluge working - write to a file then read the first line from the file...
Reply With Quote
  #6  
Old 03-19-2012, 02:28 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Yes, the main download at http://www.kinook.com/Download/VisBuildProEval.exe is the 32-bit edition.
Reply With Quote
Reply

Tags
powershell


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:51 AM.


Copyright © 1999-2023 Kinook Software, Inc.