home *** CD-ROM | disk | FTP | other *** search
/ Corel Draw 6 / corel-draw-6-cd1.iso / draw / calendar.csc < prev    next >
Text File  |  1995-08-18  |  6KB  |  183 lines

  1. REM Generates a calendar
  2. REM Calendar.csc 21 July 1995
  3.  
  4. REM This script applies a preset style to the month of your choice.
  5. REM It was designed to place an image at the top of the calendar and 
  6. REM a border around the calendar. For best resuts, the border should from the 
  7. REM Border section of the clipart disk.
  8.  
  9. DECLARE SUB getweekday (BYVAL wkd as date, BYREF wkday%)
  10.  
  11. DIM month$(12), weekday$(7), daysinmonth%(12)  'arrays to hold values
  12. DIM info%, days&, yr&        'Variables for passing be reference
  13. DIM DayID&(7), DateID&(5, 7)
  14. DIM NumID&(35)
  15.  
  16. month(1) = "January"        'stores the strings for the months
  17. month(2) = "February"
  18. month(3) = "March"
  19. month(4) = "April"
  20. month(5) = "May"
  21. month(6) = "June"
  22. month(7) = "July"
  23. month(8) = "August"
  24. month(9) = "September"
  25. month(10) = "October"
  26. month(11) = "November"
  27. month(12) = "December"
  28.  
  29. weekday(1) = "Sun"        'stores the strings for the weekday
  30. weekday(2) = "Mon"
  31. weekday(3) = "Tues"
  32. weekday(4) = "Wed"
  33. weekday(5) = "Thur"
  34. weekday(6) = "Fri"
  35. weekday(7) = "Sat"
  36.  
  37. daysinmonth(1) = 31            'stores the number of days in each month
  38. daysinmonth(2) = 28            'febuary leap years taken into account later
  39. daysinmonth(3) = 31
  40. daysinmonth(4) = 30
  41. daysinmonth(5) = 31
  42. daysinmonth(6) = 30
  43. daysinmonth(7) = 31
  44. daysinmonth(8) = 31
  45. daysinmonth(9) = 30
  46. daysinmonth(10) = 31
  47. daysinmonth(11) = 30
  48. daysinmonth(12) = 31
  49.  
  50.  
  51. BEGIN DIALOG D1 266, 93, "Calendar Helper"
  52.     TEXT  29, 12, 50, 8, "&Month:"
  53.     LISTBOX  29, 22, 68, 55, Month$, mon%
  54.     TEXT  110, 12, 50, 8, "Year:"
  55.     SPINCONTROL 135, 12, 43, 14, Year&
  56.     PUSHBUTTON  204, 46, 54, 16, "Image..."
  57.     PUSHBUTTON  204, 66, 54, 16, "Border..."
  58.     OKBUTTON  204, 6, 54, 16
  59.     CANCELBUTTON  204, 26, 54, 16
  60. END DIALOG
  61.  
  62. year& = 1995
  63. mon = 8
  64.  
  65. RETRY:
  66. return% = DIALOG(D1)
  67. IF CANCEL THEN STOP
  68.  
  69. IF return = 3 then        'Choose bitmap
  70.     bmpfile$ = GETFILEBOX("*.BMP", "Choose your favorite BITMAP file")
  71.     GOTO RETRY
  72.  
  73. ELSEIF return = 4 then        'Choose border
  74.     borderfile$ = GETFILEBOX("*.CMX", "Choose your favorite Border")
  75.     GOTO RETRY
  76. ENDIF
  77.  
  78. REM Change num days in febuary if leap year
  79. IF (year MOD 4 = 0 AND year MOD 100 <> 0) OR year MOD 400 = 0 then         'if leap year
  80.     DaysInMonth(2) = 29
  81. END IF
  82.  
  83. WITHOBJECT DRAW
  84. .FileNew
  85.  
  86. REM Set up the page
  87. .SetPageSize FROMINCHES(8.5), FROMINCHES(11)
  88. .SetPageLayout 1
  89.  
  90. REM Import the Bitmap
  91. IF bmpfile <> "" THEN
  92.     .FileImport bmpfile$
  93.     .SetSize FROMINCHES(7.5), FROMINCHES(3.5)
  94.     .SetReferencePoint 7
  95.     .SetPosition FROMINCHES(-3.75), FROMINCHES(1.5)
  96.     bmpID& = .GetObjectsCDRStaticID()
  97. END IF
  98.  
  99. REM Import the border
  100. IF borderfile <> "" THEN
  101.     .FileImport borderfile$
  102.     .ApplyUniformFillColor 3, 255, 0, 255, 0
  103. END IF
  104.  
  105. REM Put the name of the month below the image
  106. .CreateArtisticText Month(mon)
  107. .SetSize FROMINCHES(4.5), FROMINCHES(0.75)
  108. .SetReferencePoint 7
  109. .SetPosition FROMINCHES(-2.25), FROMINCHES(0.75)
  110. .ApplyFountainFill 0, 0, 0, 900, 50, 0, 0, 27
  111. .SetFountainFillColor 100, 2, 100, 100, 0, 0
  112. .SetFountainFillColor 0, 2, 100, 0, 0, 0
  113.  
  114. REM Put the year at the bottom
  115. .CreateArtisticText STR(Year)
  116. .SetCharacterAttributes 0, 4, "Algerian", 13, 1000, 0, 0, 0, 0, 1000, 0, 0, 0 
  117. .SetReferencePoint 7
  118. .SetPosition FROMINCHES(-2.25), FROMINCHES(-5)
  119. .ApplyUniformFillColor 2, 0, 100, 0, 0
  120. yearID& = .GetObjectsCDRStaticID()
  121.  
  122. REM Create the days of the week
  123. For loopvar% = 1 to 7
  124.     .CreateArtisticText Weekday(loopvar)
  125.     .SetSize FROMINCHES(0.7), FROMINCHES(0.25)
  126.     IF loopvar = 6 THEN .SetSize FROMINCHES(0.5), FROMINCHES(0.25)        'Fri has to be a little smaller
  127.     .SetReferencePoint 7
  128.     .SetPosition FROMINCHES(-3.55+(loopvar% * 0.8)), FROMINCHES(0.25)
  129.     DayID&(loopvar) = .GetObjectsCDRStaticID()
  130. next loopvar
  131.  
  132. '************************Getting weekday of first day**********************************
  133. 'Need the date for the first day of month
  134. DIM firstday as date
  135. REM Assemble first day of that month into a date variable.
  136. firstday = "1 " + Month(mon) + " " + str(Year)
  137. getweekday firstday, offby%
  138. '*********************************Getting Weekday of first day*************************
  139.  
  140. REM Create the Grid
  141. REM Offby is used to set the first day to the correct day of the week
  142. REM In loop, a square os created for each day, in the right spot.
  143.  
  144. FOR i% = 1 to DaysInMonth(mon)
  145.     Row% = FIX((OFFBY + i)/ 7) + 1    'Row = that day / 7 (7 days in a row of the calENDar)
  146.     Col% = ((OFFBY + i) MOD 7) + 1    'Col = That day MOD 7 (Column is like the remainder of the row division)
  147.     topedge& = FROMINCHES(0.6 - (row * 0.7))
  148.     leftedge& = FROMINCHES( -3.55 + (col * 0.8))
  149.     .CreateRectangle topedge, leftedge, (topedge - FROMINCHES(0.6)), leftedge + FROMINCHES(0.7), 0
  150. NEXT i
  151.  
  152. REM Create the Numbers
  153. REM This is very similar to the grid section
  154. FOR i% = 1 to DaysInMonth(mon)
  155.     Row% = FIX((OFFBY + i)/ 7) + 1
  156.     Col% = ((OFFBY + i) MOD 7) + 1
  157.     bottomedge& = FROMINCHES(0.3 - (row * 0.7))
  158.     leftedge& = FROMINCHES( -3.55 + (col * 0.8))
  159.         .CreateArtisticText STR(i)
  160.         .SetReferencePoint 7
  161.         .SetPosition leftedge, bottomedge
  162.         NumID(i) = .GetObjectsCDRStaticID()
  163. NEXT i
  164.  
  165. REM This just makes a colored background instead of white.
  166. .CreateRectangle FROMINCHES(5.5), FROMINCHES(-4.25), FROMINCHES(-5.5), FROMINCHES(4.25), 0
  167. .ApplyUniformFillColor 2, 40, 0, 0, 0
  168. .OrderToBack
  169.  
  170. END WITHOBJECT
  171.  
  172. '*********************************Getting Weekday********************************
  173.  
  174. REM This SUB returns a number which indicates which day of the week a date refers to
  175. REM Basically it uses a MOD command and uses an offset value
  176. SUB getweekday(wkd as date, wkday%)
  177.     CONST offset = 4
  178.     weektemp& = INT(wkd) + offset
  179.     wkday = (weektemp MOD 7) + 1
  180. END SUB
  181. '*********************************Getting Weekday********************************
  182.  
  183.