Previous Next        Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Procedures and Subroutines / PROCEDURE
back
+ Start Here   
+ Background   
+ Common Midas Concepts   
+ Getting Started - Part 1   
+ Getting Started - Part 2   
+ Working with Files   
+ Option Trees   
- Macros - Part 1 (Basics)   
   + Macro Basics   
   + Loops and Control Structures   
   - Procedures and Subroutines   
      - PROCEDURE   
      - SUBROUTINE   
      - CALL   
      - Lab 1 - Macro Procedures   
         - Instructions   
         - Solution   
      - Lab 2* - Macro Procedures   
         - Instructions   
         - Solution   
   + Pipes in a Macro   
   + Messages in a Macro   
+ Macros - Part 2 (Graphics)   
+ NetBeans - Part 1 (Setup)   
+ NetBeans - Part 2 (GUIs)   
+ NetBeans - Part 3 (Profiler)   
+ Eclipse - Part 1 (Setup)   
+ Eclipse - Part 2 (GUIs)   
+ Primitives   
+ WebStart   
+ Maps & Imagery   
+ X-Midas Interoperability   
+ RMIF & Remoting   
+ Installing NeXtMidas   
+ Support & Maintenance   
+ File Handlers   


  • 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:
Duke 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.

back