Home FAQ Getting Started Why is my old script broken?
24 | 01 | 2018
Why is my old script broken? PDF Print E-mail
Written by Ghoti   
Saturday, 02 August 2008 11:39

It appears as though mm2k6 has always treated if statements differently than mm2000. If statements in mm2k6 are very strict about not allowing mixed string and numeric conditions. All string variables are replaced with their contents surrounded in double quotes while numeric varialbe remain unquoted. Variables which have not been initialized with a value will almost always result in a problem in the if statement and the if condition will be treated as false. This is because uninitialized variables are treated as strings and variables initialized with /empty return null so half the condition will be missing.

For example:

/if {$MyVar = 0}{/showme {true}}{/showme {false}}

  • If MyVar was never set this if becomes "$MyVar" = 0 raising an error because the left is string and the right is numeric. The error will be sring variables must use quotes.
  • if /empty MyVar was done then the if becomes = 0 rasing an error because there is only half a condition
  • If /var {MyVar}{1} or equivalent was done then the if works and returns false

/if {$MyVar = $RoomName}{/showme {true}}{/showme {false}}

  • Even if MyVar or RoomName have previously been set to some string this condition will fail - even if the strings are the same. Strings inside /if statements must be surrounded by double quotes like:

/if {"$MyVar" = "$RoomName"}{/showme {true}}{/showme {false}}

This is because of the mechanics of variable replacement. The $MyVar and the $RoomName are replaced with the actual strings they contain before the if condition is evaluated.

If your script is not working run DebugView from  MicroSoft Technet and you'll likely see the problem right away.

Also read more about /if statements in the mm2k6 Help File section about Script Flow Control

Last Updated on Tuesday, 25 May 2010 09:35