Previous Next        Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Loops and Control Structures / Lab 2* - Macro Control / Instructions
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   
      - IF   
         - Tests   
         - IF (Block)   
         - IF (One-Line)   
         - IF (Quick Check)   
      - Loops   
         - DO   
         - LOOP   
         - WHILE   
         - FOREACH   
         - BREAK and CONTINUE   
         - FORALL   
         - Summary   
      - GOTO and LABEL   
      - Lab 1 - Macro Control   
         - Instructions   
         - Solution   
      - Lab 2* - Macro Control   
         - Instructions   
         - Solution   
   + 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   


  • Lab 2 - Macro Control:
    • Create a new macro named contlab2 in the TRAIN option tree.
    • The macro should take in two parameters: a table (TAB=) and a string (PREFIX=).
    • Your macro should print out all of the values in a table. If one of the values is a table (i.e. a nested table), you will need to recursively call your macro (i.e. call your macro from inside your macro) and print out the values in that table.
    • When you are done use UPDATE to add your macro to the dictionary and try it out. The output should look similar to this:
      nM> contlab2 reg reg
      REG.CONTLAB2=M: CONTLAB2,TAB=reg,PREFIX=reg
      REG.SHELL=nxm.sys.lib.Shell@fd66a5
      REG.HANDLERS.FILE.TMP=nxm.sys.lib.DataFile
      REG.HANDLERS.FILE.RAW=nxm.sys.lib.BaseFile
      REG.HANDLERS.FILE.PRM=nxm.sys.lib.DataFile
      ...
      REG.HANDLERS.FILE.TOC=nxm.map.lib.TocFile
      REG.HANDLERS.FILE.SID=nxm.map.lib.MrSidFile
      REG.HANDLERS.PACKET.SDDS=nxm.sys.lib.SDDSPacket
      REG.HANDLERS.PACKET.ICE=nxm.ice.lib.ICEPacket
      REG.HANDLERS.RESOURCE.RAMD=nxm.ice.lib.RamDiskResource
      REG.HANDLERS.RESOURCE.XMPIPE=nxm.sys.libxm.XmPipeResource
    • Hint: You can find out if a value is a Table by seeing if it is of type nxm.sys.lib.Table.
    • Hint: If on the STARTMACRO line you use u:prefix, you will get the "untranslated" value (i.e. it won't try to resolve any of the results).
    • Hint: If your macro is much longer than 15 lines, you are on the wrong track.

back