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.
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.