Current Page: NeXtMidas Training Macros - Part 1 (Basics) Procedures and Subroutines PROCEDURE
- - | Writing a `PROCEDURE`: Procedures are one of the fundamental building blocks of a macro. They allow code to be written once and then called many times within a macro. A procedure starts with `PROCEDURE` and ends with `RETURN`.
        PROCEDURE <name> <parameters>
          ...
        RETURN
  - The rules for procedure names are the same as those for command names (starts with a letter and then can include letters, numbers, or underscores).
        PROCEDURE MYPROC <parameters>
          ...
        RETURN
  - A procedure can take in a number of parameters which are specified in the same way that parameters are listed on the `STARTMACRO` line.
        PROCEDURE MYPROC L:MYNUM[42] T:MYTABLE S:MYSTRING
          ...
        RETURN
Two important things to note: Procedures can not directly return anything (i.e. there is nothing after the `RETURN`). Procedures share a common results table with the rest of the macro.
Java Experts Take Note:
The two primary differences between a `PROCEDURE` in a Macro and a Java method are that a `PROCEDURE` does not return anything and it shares variable-name-space with the rest of the macro.