Macro Reference

A macro is a convenient method of aliasing a LabTalk script. When you define a macro you are associating an entire script with a specific name. This name can then be used as a command that invokes the associated script. Macros are useful for a number of reasons:

  • Macros can be used to overcome the 1140 byte token limit between curly braces in your script.
    In Origin, there is a limit of the number of tokens that can be included between the set of curly braces which enclose a script. This limit is currently set at 1140 bytes (after substitution). If a script exceeds this limit it can be shortened by replacing a portion of its code with a macro command name that has been previously associated with the replaced code. This works because when calculating the number of tokens included between the curly braces of a script, Origin counts the length of any included macro name and not the length of the macro's associated script.
  • Macros can also be a useful device when attempting to develop modular code.
    Modular code is beneficial for many reasons. Modular code can improve script readability by replacing unwieldy blocks of code with mnemonic macro names. The readability and maintainability of a script can also be improved by replacing repetitive or similar blocks of code with multiple calls of the same macro. Different arguments can be passed to each macro call, if need be, to individually tailor the code that gets executed. Macros improve the maintainability of scripts by reducing the number of possible modifications required in the future. If modifications to a script are required it is easier to change the code in one reused macro rather than the code in many repeated blocks of code. Macro libraries can also be created which might reduce future development time and costs. Once a macro is written and thoroughly debugged, it can confidently be used to perform its objective anywhere in any script.
  • Macros can be used to override predefined LabTalk commands.
    Since macros are executed prior to predefined LabTalk commands, if you want to override a LabTalk command (implement your own version of the command) you can accomplish this by creating a macro with the same name as the predefined command. The overriding macro command can be deleted at any time and the predefined command will automatically be restored.