Previous Next         Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Lab 5 / Instructions
Start Here   
Background   
Common Midas Concepts   
Getting Started   
Working with Files   
Option Trees   
Macros - Part 1 (Basics)   
   + Macro Basics   
   + Lab 1   
   + Lab 2   
   + Loops and Control Structures   
   + Lab 3   
   + Lab 4*   
   + Procedures and Subroutines   
   - Lab 5   
      - Instructions   
      - Solution   
   + Lab 6*   
   + Pipes in a Macro   
   + Lab 7   
   + Lab 8   
   + Messages in a Macro   
   + Lab 9   
   + Lab 10   
Macros - Part 2 (Graphics)   
Primitives   
Installing NeXtMidas   
Applets & WebStart   
Mapping (NeXtEarth)   
Remote Midas InterFace (RMIF)   
Using NetBeans   
X-Midas Interoperability   
Remoting an X-Midas App.   


  • Lab 5:
    • For this lab you will be writing a macro that takes in a date in "YYYY/MM/DD" format and printing it out in words as well as indicating if the year is a leap year.
    • For this lab a template is provided with the basic outline of the macro. Copy the Lab 5 macro template and add it to the TRAIN option tree.
      • Macro Template: mcrlab5.mm
      • Make sure to save the above file as mcrlab5.mm!
    • In the macro fill the main parts of the macro as well as the setMonStr and setIsLeapYear procedures.
      • The template provided indicates what needs to be filled in.
      • Comments in the template explain how to compute whether or not a year is a leap year.
    • 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> mcrlab5 2006/09/10 
      10 September 2006 (not leap year)
      nM> mcrlab5 2000/01/1
      1 January 2000 (leap year)
    • Note: You are not allowed to use the TIMEX command or the Time class (or any other Java data/time class). Yes they exist, and yes they can do all of the same work, but that would defeat the purpose of this lab.
    • Hints:
      • Fill in the main part of the macro first, then test it. After that fill in setMonStr and test that. Finally fill in the setIsLeapYear procedure. If you try to do all of it at once and then test, you are likely to have bugs that are harder to find.
      • You will need to use the ELEM function in SEDIT to parse the "YYYY/MM/DD" date into year, month, and day.
      • When going from month number to month you will again use the ELEM function in SEDIT.
      • The IF command has built-in tests isTrue and isFalse, you will need to use at least one of these.