Kinook Software Forum

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

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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, 2184 views)
Reply With Quote
 


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 08:17 AM.


Copyright © 1999-2023 Kinook Software, Inc.