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 03-05-2004, 02:51 PM
perkincr perkincr is online now
Registered User
 
Join Date: 03-05-2004
Posts: 2
ExpandMacrosEx

I am using the ExpandMacrosEx method in a script running in the GUI. I use the following code:

Application.ExpandMacrosEx(%VAR%, vbldUndefLeave, strResult, False)

Even though I use the vbldUndefLeave as the undefTreatment parameter, the 'Enter Undefined Macro Value' dialog still appears.

I would think that the result should be that the strResult should contain the unexpanded macro if it is not defined.

----------
The above was an attempt to work around the original purpose of this script. I want to write to a file the contents of a variable %VAR% that contains text with special characters such as '%' and '['.

Is there a way to write to a file the literal text without variable expansion? I even tried to replace the '%' with '%%' in the variables. But when attempting the replace the '%' character is still being evaluated as a macro.

Help on either of these issues would be appreciated.
Reply With Quote
  #2  
Old 03-05-2004, 06:35 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Quote:
I am using the ExpandMacrosEx method in a script running in the GUI. I use the following code:

Application.ExpandMacrosEx(%VAR%, vbldUndefLeave, strResult, False)

Even though I use the vbldUndefLeave as the undefTreatment parameter, the 'Enter Undefined Macro Value' dialog still appears.
If you have that code in a step field, the first thing it will do (before evaluating the script code) is expand any macros in the string. To prevent it from doing that, use double percent chars (i.e., Application.ExpandMacrosEx("%%VAR%%"...). However, that function is not actually callable from script code since it takes a non-variant in/out parameter.

Quote:
I want to write to a file the contents of a variable %VAR% that contains text with special characters such as '%' and '['.

Is there a way to write to a file the literal text without variable expansion?
A run script step with this VBScript code would do it (uses the DOSCMD macro as an example):

vbld_FSO().CreateTextFile("%TEMP%\xyz.txt").Write( vbld_AllMacros()("DOSCMD").Value)
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 05:38 PM.


Copyright © 1999-2023 Kinook Software, Inc.