Kinook Software Forums

Kinook Software Forums (http://www.kinook.com/Forum/index.php)
-   [VBP] Third Party Tools (http://www.kinook.com/Forum/forumdisplay.php?f=3)
-   -   Returning variable from PowerShell subroutine (http://www.kinook.com/Forum/showthread.php?t=4986)

cholzwarth 03-19-2012 10:16 AM

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?

kinook 03-19-2012 11:10 AM

One way to return values from PowerShell to VBP is via global macros.
http://www.kinook.com/VisBuildPro/Ma...ershelltab.htm

cholzwarth 03-19-2012 12:30 PM

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()

kinook 03-19-2012 01:38 PM

If you're running v7, you'll need to use VisBuildSvr7.Application (version-independent ProgID is new in v8).

cholzwarth 03-19-2012 02:08 PM

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

kinook 03-19-2012 02:28 PM

Yes, the main download at http://www.kinook.com/Download/VisBuildProEval.exe is the 32-bit edition.


All times are GMT -5. The time now is 09:53 PM.


Copyright 1999-2019 Kinook Software, Inc.