Previous Next         Current Page: NeXtMidas Training / Macros - Part 1 (Basics) / Lab 6* / 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   
   - Lab 6*   
      - Instructions   
      - Solution   
   + 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 6:
    • 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 the day of the year (you can assume all dates fall after 1900).
    • It is suggested that you start with what you did for Lab 5 (or make a copy of the solution to Lab 5) and copy it to mcrlab6.mm.
    • Add in a setDayOfWeekStr procedure that will find the day of the week corresponding with the date. Here is a template you can use for the procedure.
      ! Computes the day of the week and sets dayOfWeekStr
      ! with the day of the week for the date.
      procedure setDayOfWeekStr L:year S:month L:day
        set count 0
        
        ! Compute the number of days from 1900 to the start of this year
        
        
        
        ! Compute the number of days from the start of this year
        ! to the start of this month
      
        
        
        
        ! Add in the number of days for this month
      
        
        
        
        ! Now take ((count mod 7) + 1) to figure out which day
        ! of the week to use. This value can map directly into
        ! the DAYS list using SEDIT.
        
        
        
      return
    • 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> mcrlab6 2000/01/1 
      Saturday, 1 January 2000
      nM> mcrlab6 2006/09/10     
      Sunday, 10 August 2006