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

 Related 
Contents
Conditionals
  #CASE
  #IF
  #SWITCH
  %pat
  Conditionals
Feature Reference
  Aliases
  Macros
  Variables
  Functions
  Classes
  Triggers
  Buttons
  Gauges
  Paths
  Menus
  Events
  Modules
  Windows
  Packages
  Shared Package Library
  Package Editor
  Docked Windows
  Customizeable Toolbars
  Sessions
  Expressions
  Automapper Module
  Database Module
  Syntax Checking
  Tab Completion
  Status items
  Preferences
  Simutronics Support
  Pueblo Emulation
  Keyboard shortcuts
  MXP
  Threads
  ATCP
  Script Debugger
  Timestamps
  Lua Scripting
Related Links:
  %eval
  %if
  #IF
  #MATH
  Introduction to Buttons
Expressions [[cmud_Expression]] 
CMUD implements full expressions. Expressions can contain variables, and most common operators. Parenthesis can be used to override default operator precedence. When evaluating an operation, if all parameters of the operation are numeric, then a numeric operation is used, otherwise a string operation is used. The following operators are recognized (v1 and v2 represent variables, or other expressions). The list is in precedence order, with the highest precedence operators at the top.

!v1 return the logical NOT of value1
not v1 same as above
-v1 return the negative of value1
v1 * v2 multiply value1 by value2
v1 / v2 divide v1 by v2. Any fraction is discarded.
v1 \ v2 divide v1 by v2 and return the modulus
v1 + v2 add value1 to value2. If values are not numeric, the text values are concatenated.
v1 - v2 subtract value2 from value1
v1 = v2 true if value1 is the same as value2
v1 > v2 true if value1 is greater than value2
v1 < v2 true if value1 is less than value2
v1 >= v2 true if value1 is greater than or equal to value2
v1 <= v2 true if value1 is less than or equal to value2
v1 <> v2 true if value1 is not equal to value2
v1 != v2 true if value1 is not equal to value2
v1 =~ v2 true if the string v1 matches the pattern in v2
v1 LIKE v2 same as above (added in v2.0)
v1 && v2 returns the logical AND of value1 and value2
v1 AND v2 same as above
v1 || v2 returns the logical OR of value1 and value2
v1 OR v2 same as above
v1 XOR v2 returns the logical XOR of value1 and value2


If the pattern matching =~ or LIKE operator is used, any saved pattern parameters are available through the %pat function.

The constants: true, yes, on are defined with a value of 1, and the constants: false, no, off are defined with a value of 0.

Keep in mind that the AND, OR, XOR, and NOT operators are logical operators and not bitwise operation. For bitwise operations, use the various bitwise functions in CMUD. For example: (2 AND 4) is true using the logical operation, but %bitand(2,4) returns zero, which is false!
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net