Macro Scheduler 15

User Defined Variables

As well as system variables, which are pre-set, variables can be assigned by script commands which return variables, and by the Let command which allows you to create variables at any time.  All variables have global scope (are available to the entire script once created).


The Let command is used to assign a value to a variable like so :


Let>Name=Freddy Mercury


The first time a variable is assigned a value, that variable is created.  Subsequently, it's value is modified.


Variables can then be passed into other functions as one of the parameters.  For example, assuming the above Let command has taken place, the following command will display a message box containing the words 'Freddy Mercury' :




If Name did not exist as a variable, the message box would simply display the word 'Name'.


Commands always check to see if a parameter passed to it is a variable.  If a variable with that name exists, the value assigned to that variable is used, otherwise just that literal value is used.


All commands which accept a value can also accept a variable in place of that value.


For example, the following command would send the text 'Freddy Mercury' to the current window :




In some cases a variable must be embedded within a string.  This can be achieved using the % operator.  In the following example a message is displayed saying 'Hello Freddy Mercury' :


Message>Hello %Name%


The system variable CRLF can be used to force a new line in a message box.  Therefore, a list can be built up like so :


Message>1 : first line %CRLF%2 : second line %CRLF%3 : third line


It is possible to ask the user for a value, using the Input box :


Input>path,Please enter directory to create :


This would prompt the user to enter a directory name to create, which would then be assigned to the variable path.  We could then use it in the CreateDir command as follows :




The If command can be used to check the value of a variable :