TrueGui Help
Macros

Glossary Item Box

 

The TrueGUI command syntax supports user-defined macros. A macro is a user symbol whose value is a text string that is directly substituted into a command replacing the macro symbol in any command that uses it. 

A macro is defined by using the Macro command followed by the macro symbol and an assigning text string. The text string may be a complete or partial command. 

Some valid macro commands are: 

Macro tom = button1.Width + 15

MACRO M1 = MyForm.Close()

macro fnc1 = (X + Y - Z)

 

Macros may also refer to other macros within their definition: 

Macro M2 = ((fnc1 + tom) - 15)

 

When the M2 macro string is stored, the macro symbols fnc1 and tom are stored as their symbols and not as the text string that will replace them. Macro symbols are only replaced by their defined text strings when they are used in an executable TrueGUI command, just before that command is parsed and executed. 

Macro symbols may be reassigned to a new text string at any time. In this case, the macro symbol is not replaced in the command by the text string, but rather, the macro is redefined to be the new text string. 

Once a symbol is defined as a macro symbol, it cannot be redefined to become a user object. This fact allows a macro symbol to be used as the left side of an assignment statement.

 

Example:

Macro M2 = MyForm.textBox1.Text     ! the M2 macro symbol is redefined to "MyForm.textBox1.Text"

M2 = `This text`                     ! MyForm.textBox1.Text is loaded with "This text"

 

You will want to experiment with macros to see just how they operate.