Current Page: NeXtMidas Training Macros - Part 1 (Basics) Loops and Control Structures Lab 2* - Macro Control Instructions
- - | 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.