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 11-12-2009, 12:51 PM
Rogier Rogier is online now
Registered User
 
Join Date: 09-09-2004
Location: the Netherlands
Posts: 40
Script expression for macros that are not always defined?

For every action, you can set a condition "build only if macro or expression ... is true/false/defined/undefined/etc."

Now, occasionally I want to build a step if some macro (let's say "UnsureMacro") is either not defined, or if it's true.

To pull this off I've been messing with a temporary macro "DO_IT" which I first set to true (always), and then (in a separate set macro action) set it to %UnsureMacro% if UnsureMacro is defined.
Then in the actual action, I enable the condition "only if %DO_IT% is true".

This works, but it feels kinda clumsy. Is there some script expression in which I can combine this, so I don't have to mess with a temp macro and separate actions?

I tried stuff like this:
Code:
[((vbld_AllMacros()("UnsureMacro")) Is Nothing) OR ((vbld_AllMacros()("UnsureMacro"))<>"0")]
But that still results in an error if UnsureMacro is not defined.

If I write a complete script for this, I can do it, but is there perhaps a neat tight single expression that does the same?

Last edited by Rogier; 11-12-2009 at 01:13 PM.
Reply With Quote
  #2  
Old 11-12-2009, 01:31 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
VBScript doesn't do short-circuit evaluation, so you would need to create a project or global script function (View | Other Windows | Script Editor) like this:
Code:
Function CheckMacro(name)
  CheckMacro = False
  If vbld_AllMacros()(name) Is Nothing Then
    CheckMacro = True
  Else
    CheckMacro = CBool(vbld_AllMacros()(name))
  End If
End Function
and reference this function in the rule:

build only if macro or expression
[CheckMacro("UnsureMacro")]
is true

http://www.kinook.com/VisBuildPro/Ma...ripteditor.htm
http://www.kinook.com/VisBuildPro/Ma...xpressions.htm
http://www.kinook.com/VisBuildPro/Manual/buildrules.htm
Reply With Quote
  #3  
Old 11-12-2009, 01:34 PM
Rogier Rogier is online now
Registered User
 
Join Date: 09-09-2004
Location: the Netherlands
Posts: 40
Ok, thanks, will set things up like that.
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:06 PM.


Copyright © 1999-2023 Kinook Software, Inc.