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 07-13-2010, 07:56 AM
wellilein wellilein is online now
Registered User
 
Join Date: 11-30-2005
Posts: 53
Macro containing brackets

I have recorded the output of a build step (namely the VMWare list processes action). The output of this step contains brackets for one of the processes ([System process]) and is multiline (one process per line).

I would like to check whether a specific process is running, so I perform additional operations on the macro value. However, I can't get it work. In this simplified example I am looking for svchost in the list of running processes. Instead of a temporarily assigned macro I use a fixed project macro to reproduce.

Code:
Approach 1: Simply use the Instr() VBScript function.
[Instr(1, "%VMPROCESSES%", "svchost")]
This fails due to an unterminated string because the macro is expanded immediately, resulting in a new line. That's clear.

Code:
Approach 2: Use Application.ExpandMacros
[Application.ExpandMacros("%VMPROCESSES%")]
This of course has the same issue and I need to use double % signs to pass %VMPROCESSES% as a string to be expanded later by the method.

Code:
Approach 3: Double percentage
[Application.ExpandMacros("%%VMPROCESSES%%")]
This complains about the brackets, although my understanding is that only macros are expanded, not functions. For macros and functions, there is ExpandMacrosAndScript().

Code:
Approach 4: use vbld_AllMacros()
[vbld_AllMacros()("VMPROCESSES").Value]
This also complains about brackets.

Code:
Funny: Message box is ok
[msgbox (vbld_AllMacros()("VMPROCESSES").Value)]
Code:
Approach 5: doubling the brackets once
[Replace(Replace((vbld_AllMacros()("VMPROCESSES").Value), "[[", "[[[["), "]]", "]]]]")]
This does not work.

Code:
Funny: with a message box, it works, but replacement is not done.
[msgbox (Replace(Replace((vbld_AllMacros()("VMPROCESSES").Value), "[[", "[[[["), "]]", "]]]]"))]
I attached my build script.
Steps 1, 2, 3, 4, 6 fail.
Steps 5, 7, 8 with message boxes are successful (but replacements are not made).
Attached Files
File Type: bld macro issue.bld (3.8 KB, 2174 views)
Reply With Quote
  #2  
Old 07-13-2010, 08:04 AM
wellilein wellilein is online now
Registered User
 
Join Date: 11-30-2005
Posts: 53
I forgot the version number

I am using Visual Build 7.5b.
Reply With Quote
  #3  
Old 07-13-2010, 05:13 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
If the program's output contained

[System Process]

the output macro (i.e., LASTSTEP_OUTPUT) should contain the text with the brackets double (escaped) like

[[System Process]]

See the attached sample.
Attached Files
File Type: bld macros.bld (2.2 KB, 2041 views)
Reply With Quote
  #4  
Old 07-19-2010, 07:48 AM
wellilein wellilein is online now
Registered User
 
Join Date: 11-30-2005
Posts: 53
Cool Thank you

Thank you. As I am saving the process list in a macro, I now use the Set Macro build step and I assign the value
Code:
[Replace(Replace(vbld_AllMacros()("LASTSTEP_OUTPUT").Value,"[[","[[[["), "]]", "]]]]")]
This helps me bypassing the volatile %LASTSTEP_OUPUT% macro.
Reply With Quote
  #5  
Old 07-19-2010, 07:56 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
You could also use vbld_EscapeString when assigning your macro value.
http://www.kinook.com/VisBuildPro/Ma...scriptmisc.htm
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 06:26 PM.


Copyright © 1999-2023 Kinook Software, Inc.