|
#1
|
|||
|
|||
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")] Code:
Approach 2: Use Application.ExpandMacros [Application.ExpandMacros("%VMPROCESSES%")] Code:
Approach 3: Double percentage [Application.ExpandMacros("%%VMPROCESSES%%")] Code:
Approach 4: use vbld_AllMacros() [vbld_AllMacros()("VMPROCESSES").Value] Code:
Funny: Message box is ok [msgbox (vbld_AllMacros()("VMPROCESSES").Value)] Code:
Approach 5: doubling the brackets once [Replace(Replace((vbld_AllMacros()("VMPROCESSES").Value), "[[", "[[[["), "]]", "]]]]")] Code:
Funny: with a message box, it works, but replacement is not done. [msgbox (Replace(Replace((vbld_AllMacros()("VMPROCESSES").Value), "[[", "[[[["), "]]", "]]]]"))] Steps 1, 2, 3, 4, 6 fail. Steps 5, 7, 8 with message boxes are successful (but replacements are not made). |
#2
|
|||
|
|||
I forgot the version number
I am using Visual Build 7.5b.
|
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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,"[[","[[[["), "]]", "]]]]")] |
#5
|
|||
|
|||
You could also use vbld_EscapeString when assigning your macro value.
http://www.kinook.com/VisBuildPro/Ma...scriptmisc.htm |
|
|