home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / calmacro.zip / Calendar.dml (.txt) next >
DeScribe Document  |  2000-01-28  |  21KB  |  155 lines

  1. DeScribe  Copyright DeScribe, Inc., 1988, 1989
  2. Info 1
  3. Info 2
  4. Info 3
  5. Info 4
  6. Macro
  7. Courier
  8. !   This macro prompts the user for a month and a year,
  9. !   calls up the Calendar Layout and fills in the headings
  10. !   with appropriate values. This modification should work
  11. !   for years 1950 through 2049.
  12. VAR month
  13. VAR day
  14. VAR year
  15. VAR noDays
  16. VAR daySeq
  17. VAR mo
  18. VAR count
  19. PROCEDURE DaysInMonth
  20. !   arguments are m and y, returns d
  21.     SET d TO 31           
  22.     IF m=1 THEN SET mo TO "JANUARY" RETURN END IF
  23.     IF m=3 THEN SET mo TO "MARCH" RETURN END IF
  24.     IF m=5 THEN SET mo TO "MAY" RETURN END IF
  25.     IF m=7 THEN SET mo TO "JULY" RETURN END IF
  26.     IF m=8 THEN SET mo TO "AUGUST" RETURN END IF
  27.     IF m=10 THEN SET mo TO "OCTOBER" RETURN END IF
  28.     IF m=12 THEN SET mo TO "DECEMBER" RETURN END IF
  29.     SET d TO 30
  30.     IF m=4 THEN SET mo TO "APRIL" RETURN END IF
  31.     IF m=6 THEN SET mo TO "JUNE" RETURN END IF
  32.     IF m=9 THEN SET mo TO "SEPTEMBER" RETURN END IF
  33.     IF m=11 THEN SET mo TO "NOVEMBER" RETURN END IF
  34.     SET mo TO "FEBRUARY"
  35.     SET z TO year MOD 4
  36.     IF z = 0 THEN
  37.         SET d to 29
  38.     ELSE
  39.         SET d TO 28
  40.     END IF
  41. END PROCEDURE
  42. PROCEDURE CheckMon
  43. !   Call with:  month=month
  44. !               year=year
  45. !   Exits with: noDays=no. of days in month
  46. !               monthName=text of month name
  47. !               daySeq=first day (0=Sun, 1=Mon, ..., 6=Sat)
  48.     SET count TO year * 365
  49.     SET q TO year - 1
  50.     SET q TO q / 4
  51.     SET count TO count + q
  52.     SET m TO 1
  53.     SET y TO year
  54.     REPEAT
  55.         EXIT WHEN m = month
  56.         CALL DaysInMonth
  57.         SET count TO count + d
  58.         SET m TO m + 1
  59.     END REPEAT
  60.     IF year = 00 THEN
  61.     SET x TO count+6
  62.     SET z TO x MOD 7
  63.     SET daySeq TO z
  64.     SET m TO month
  65.     CALL DaysInMonth
  66.     SET noDays TO d
  67.     RETURN END IF
  68.     IF year >= 50 THEN
  69.     SET x TO count+1
  70.     SET z TO x MOD 7
  71.     SET daySeq TO z
  72.     SET m TO month
  73.     CALL DaysInMonth
  74.     SET noDays TO d
  75.     ELSE
  76.     SET x TO count
  77.     SET z TO x MOD 7
  78.     SET daySeq TO z
  79.     SET m TO month
  80.     CALL DaysInMonth
  81.     SET noDays TO d
  82.     END IF
  83. END PROCEDURE
  84. MACRO Calendar1
  85.     SET MacroDialogTitle to 
  86. Set up Calendar
  87.     MSET "Month (1-12)" TOVALUE month
  88.     MSET "Year (94, for example)" TOVALUE year
  89.     MGET 
  90. To create a Calendar table in a new DeScribe document, type the desired month and year.
  91.     IF month < 1 THEN QUIT END IF
  92.     IF month > 12 THEN QUIT END IF
  93.     !year should be 0 through 99
  94.     IF year < 0 THEN QUIT END IF
  95.     IF year > 99 THEN QUIT END IF
  96.     CALL CheckMon 
  97.     NewDocumentFile "CALENDAR.dwp"
  98.     SET SelectedFrame TO 
  99.     CursorHome
  100.     PUT mo
  101.     PUT " "
  102.     KeyTab
  103.     IF year >= 50 THEN PUT 1900 + year END IF
  104.     IF year <  50 THEN PUT 2000 + year END IF
  105.     CursorEndLine
  106.     CursorEndLine
  107.     CursorEndLine
  108.     CursorEndLine
  109.     CursorEndLine
  110.     CursorEndLine
  111.     CursorEndLine
  112.     TableCellRight
  113.     REPEAT
  114.         EXIT WHEN daySeq = 0
  115.         TableCellRight
  116.         SET daySeq TO daySeq - 1
  117.     END REPEAT
  118.     SET d TO 1
  119.     REPEAT
  120.         PUT d
  121.         EXIT WHEN d = noDays
  122.         SET d TO d + 1
  123.         TableCellRight
  124.     END REPEAT
  125.     TableModifyStart
  126.     SET TableTabCreateRows TO FALSE
  127.     TableProcessChanges
  128.     CursorHome
  129.     SET SelectedFrame TO 
  130. DeNote
  131. END MACRO
  132. DeScribe Glossary
  133. Create date
  134. Create time
  135. Document name
  136. File name
  137. Pages
  138. Pages (Alphabetic lower case)
  139. Pages (Alphabetic upper case)
  140. Pages (Roman lower case)
  141. Pages (Roman upper case)
  142. Print date
  143. Print time
  144. Revisions
  145. Save date
  146. Save time
  147. August 4, 1994
  148. 12:31 P.M.
  149. Calendar4.dml
  150. G:\DeScribe\Macros\Calendar4.dml
  151. January 28, 2000
  152. 9:37 P.M.
  153. January 28, 2000
  154. 9:38 P.M.
  155.