Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Changes for zMUD users
  Importing zMUD files
  New Features
  New Commands
  New Functions
  Compiled scripts
  [] and <> syntax removed
  %%1 syntax removed
  AND OR operators changed
  Class specifier changes
  #PRIORITY command
  Quotes around %1..%99
  #VAR command
  #MENU command
  64-bit integers
  #GALIAS and #GVAR
  %lastcom
  Expression optimization
  Aliases (Auto-append)
  atconnect alias replaced with Events
  #GAG in #ONINPUT trigger
  #T+ vs #CLASS
  Tab completion changes
  Multi-threaded #WAIT
  %btncol arguments reversed
  Multiplaying :window: syntax
  Start lines with commands
  #FUNCTION command
  Variable assignment syntax
Expression optimization [[cmud_changes_expression]] 
Logical (boolean) expressions in CMUD are optimized for speed.

For example, look at the AND operation:

(expression1) AND (expression2)

This full expression is True only if BOTH expression1 AND expression2 are True. When CMUD starts running this expression, if it determines that expression1 is False, then it can stop right away and never even look at expression2. No matter what value expression2 has, if expression1 was false, then the entire full expression is also going to be false.

It is similar with OR operations:

(expression1) OR (expression2)

This is True if EITHER expression1 is True OR expression2 is True. So, when CMUD starts testing this expression, if it determines that expression1 is True, then it doesn't need to evaluate expression2 because no matter what value expression2 has, the result is still going to be true.

These optimizations help speed up scripts. It can also be used to prevent accessing undefined variables. For example:

Code:
ComVar = %comcreate("Outlook.Application")
#IF (@ComVar AND (@ComVar.GetNameSpace("MAPI").Folders(1) = "InBox")) {...}


In this case, if the @ComVar isn't defined, then the GetNameSpace property is never referenced, which prevents a runtime error in your script. zMUD had to trap and ignore these kind of errors since the entire expression was *always* evaluated.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net