Previous Next        Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Macro Basics / Macro Structure
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   
      - What is a Macro?   
      - Types of Macros   
      - Local vs Global Results   
      - Macro Structure   
      - Lab 1 - Macro Basics   
         - Instructions   
         - Solution   
      - Lab 2 - Macro Basics   
         - Instructions   
         - Solution   
   + Loops and Control Structures   
   + Procedures and Subroutines   
   + 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   


  • Macro Structure:
    • The main part of a macro starts with STARTMACRO and ends with ENDMACRO. Between them are the commands to run.
      startmacro
        say "Hello World!"
      endmacro
    • The STARTMACRO line is also used to define any parameters that will be passed into the macro. They are always specified using type-colon-name (e.g. d:frequency for a parameter named frequency that is a double).
      startmacro s:name
        say "Hello there ^{name}!"
      endmacro
    • User Macros can also include default values for the parameters given inside square brackets ([..]) after the parameter name.
      startmacro s:name[Mickey]
        say "Hello there ^{name}!"
      endmacro
    • Comments can be included in a macro that do not affect its execution. A comment begins with an exclamation point (!) and ends at the end of a line. (Exclamation points inside quotes are part of the quote and not a comment.)
      startmacro
        ! This is a comment
        say "Hello World!"  ! This is another comment
      endmacro
    • If a command is too long to fit on one line, it can be continued onto the next line by adding an ampersand (&) at the end of the line. The ampersand and any leading white space at the beginning of the next line are ignored.
      startmacro
        say "Hello &
             World!"
      endmacro
X-Midas Users Take Note:
X-Midas does not require STARTMACRO at the beginning of the macro. NeXtMidas enforces this rule and will give an exception if the STARTMACRO is missing.

back