Previous Next        Current Page: NeXtMidas Training / Option Trees / Lab 2 / Instructions
Start Here   
Background   
Common Midas Concepts   
Getting Started - Part 1   
Getting Started - Part 2   
Working with Files   
Option Trees   
   + Overview   
   + Using an Option Tree   
   + Lab 1   
   + Creating an Option Tree   
   + Command Dictionary   
   + Building an Option Tree   
   - Lab 2   
      - Instructions   
      - Solution   
Macros - Part 1 (Basics)   
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   
Applets & WebStart   
Maps & Imagery   
X-Midas Interoperability   
RMIF & Remoting   
Installing NeXtMidas   
Support & Maintenance   
File Handlers   


  • Lab 2:
    • For this lab you will create an option tree called TRAIN that you will use again for the labs in subsequent modules.
    • What you need to do:
      1. Decide where you want to put your option tree. (Hint: your home directory is a good location. e.g. $HOME/nmopts/nxm/train)
      2. Create the option tree and add it to your path.
        • You may use OPTION to create the option tree or do it manually.
        • If you do it manually you will need to make sure not to forget the mcr and prim sub-directories. You will also need to make sure to copy over the template commands.cnf file.
        • Do not try the "symbolic link" approach, since it requires you to have write access to the NeXtMidas installation (i.e. to put symbolic link under $NMROOT/nxm/ that points to your option tree).
        • Do not try the "back-link" approach, it will cause problems for later labs.
      3. Add the following commands to your option tree (Be sure to use the name provided below):
        1. counter.java (primitive)
        2. sayhello.mm (macro)
      4. Use UPDATE to add each of the commands to the dictionary.
        1. COUNTER takes in two numbers, START= and END= which default to 1 and 10 respectively.
        2. SAYHELLO takes in a single string NAME= which defaults to "Anonymous".
      5. Build your option tree.
      6. Try everything out.
        nM> counter ,, 9
        INFO: Counting from 1 to 9 [COUNTER]
        INFO: Count is at 1 [COUNTER]
        INFO: Count is at 2 [COUNTER]
        INFO: Count is at 3 [COUNTER]
        INFO: Count is at 4 [COUNTER]
        INFO: Count is at 5 [COUNTER]
        INFO: Count is at 6 [COUNTER]
        INFO: Count is at 7 [COUNTER]
        INFO: Count is at 8 [COUNTER]
        INFO: Count is at 9 [COUNTER]
        INFO: Done counting [COUNTER]
        nM>
        nM>
        nM> sayhello Tony
        INFO: Hello TONY! [SAYHELLO]
      7. Tailor your NeXtMidas environment by putting a nmstartup.mm macro in your $HOME directory (e.g. /home/student/nmstartup.mm) with the following contents:
        ! customize user's NeXtMidas environment (put this into $HOME/nmstartup.mm)
        startmacro
          say "Running my (^{env.user}'s) custom nmstartup.mm macro..."
        
          ! portable way to get path to TRAIN option tree under user's home dir ($HOME/nmopts/nxm/train/)
          file name trainDir (^{env.home},nmopts,nxm,train)
        
          ! define train option tree and add it to the path
          option train trainDir
          path add train
        endmacro
        
        The next time you run nmstart, your $HOME/nmstartup.mm macro gets automatically executed; which will define your TRAIN option and add it to the path.