home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Corel Draw 6
/
corel-draw-6-cd1.iso
/
draw
/
calendar.csc
< prev
next >
Wrap
Text File
|
1995-08-18
|
6KB
|
183 lines
REM Generates a calendar
REM Calendar.csc 21 July 1995
REM This script applies a preset style to the month of your choice.
REM It was designed to place an image at the top of the calendar and
REM a border around the calendar. For best resuts, the border should from the
REM Border section of the clipart disk.
DECLARE SUB getweekday (BYVAL wkd as date, BYREF wkday%)
DIM month$(12), weekday$(7), daysinmonth%(12) 'arrays to hold values
DIM info%, days&, yr& 'Variables for passing be reference
DIM DayID&(7), DateID&(5, 7)
DIM NumID&(35)
month(1) = "January" 'stores the strings for the months
month(2) = "February"
month(3) = "March"
month(4) = "April"
month(5) = "May"
month(6) = "June"
month(7) = "July"
month(8) = "August"
month(9) = "September"
month(10) = "October"
month(11) = "November"
month(12) = "December"
weekday(1) = "Sun" 'stores the strings for the weekday
weekday(2) = "Mon"
weekday(3) = "Tues"
weekday(4) = "Wed"
weekday(5) = "Thur"
weekday(6) = "Fri"
weekday(7) = "Sat"
daysinmonth(1) = 31 'stores the number of days in each month
daysinmonth(2) = 28 'febuary leap years taken into account later
daysinmonth(3) = 31
daysinmonth(4) = 30
daysinmonth(5) = 31
daysinmonth(6) = 30
daysinmonth(7) = 31
daysinmonth(8) = 31
daysinmonth(9) = 30
daysinmonth(10) = 31
daysinmonth(11) = 30
daysinmonth(12) = 31
BEGIN DIALOG D1 266, 93, "Calendar Helper"
TEXT 29, 12, 50, 8, "&Month:"
LISTBOX 29, 22, 68, 55, Month$, mon%
TEXT 110, 12, 50, 8, "Year:"
SPINCONTROL 135, 12, 43, 14, Year&
PUSHBUTTON 204, 46, 54, 16, "Image..."
PUSHBUTTON 204, 66, 54, 16, "Border..."
OKBUTTON 204, 6, 54, 16
CANCELBUTTON 204, 26, 54, 16
END DIALOG
year& = 1995
mon = 8
RETRY:
return% = DIALOG(D1)
IF CANCEL THEN STOP
IF return = 3 then 'Choose bitmap
bmpfile$ = GETFILEBOX("*.BMP", "Choose your favorite BITMAP file")
GOTO RETRY
ELSEIF return = 4 then 'Choose border
borderfile$ = GETFILEBOX("*.CMX", "Choose your favorite Border")
GOTO RETRY
ENDIF
REM Change num days in febuary if leap year
IF (year MOD 4 = 0 AND year MOD 100 <> 0) OR year MOD 400 = 0 then 'if leap year
DaysInMonth(2) = 29
END IF
WITHOBJECT DRAW
.FileNew
REM Set up the page
.SetPageSize FROMINCHES(8.5), FROMINCHES(11)
.SetPageLayout 1
REM Import the Bitmap
IF bmpfile <> "" THEN
.FileImport bmpfile$
.SetSize FROMINCHES(7.5), FROMINCHES(3.5)
.SetReferencePoint 7
.SetPosition FROMINCHES(-3.75), FROMINCHES(1.5)
bmpID& = .GetObjectsCDRStaticID()
END IF
REM Import the border
IF borderfile <> "" THEN
.FileImport borderfile$
.ApplyUniformFillColor 3, 255, 0, 255, 0
END IF
REM Put the name of the month below the image
.CreateArtisticText Month(mon)
.SetSize FROMINCHES(4.5), FROMINCHES(0.75)
.SetReferencePoint 7
.SetPosition FROMINCHES(-2.25), FROMINCHES(0.75)
.ApplyFountainFill 0, 0, 0, 900, 50, 0, 0, 27
.SetFountainFillColor 100, 2, 100, 100, 0, 0
.SetFountainFillColor 0, 2, 100, 0, 0, 0
REM Put the year at the bottom
.CreateArtisticText STR(Year)
.SetCharacterAttributes 0, 4, "Algerian", 13, 1000, 0, 0, 0, 0, 1000, 0, 0, 0
.SetReferencePoint 7
.SetPosition FROMINCHES(-2.25), FROMINCHES(-5)
.ApplyUniformFillColor 2, 0, 100, 0, 0
yearID& = .GetObjectsCDRStaticID()
REM Create the days of the week
For loopvar% = 1 to 7
.CreateArtisticText Weekday(loopvar)
.SetSize FROMINCHES(0.7), FROMINCHES(0.25)
IF loopvar = 6 THEN .SetSize FROMINCHES(0.5), FROMINCHES(0.25) 'Fri has to be a little smaller
.SetReferencePoint 7
.SetPosition FROMINCHES(-3.55+(loopvar% * 0.8)), FROMINCHES(0.25)
DayID&(loopvar) = .GetObjectsCDRStaticID()
next loopvar
'************************Getting weekday of first day**********************************
'Need the date for the first day of month
DIM firstday as date
REM Assemble first day of that month into a date variable.
firstday = "1 " + Month(mon) + " " + str(Year)
getweekday firstday, offby%
'*********************************Getting Weekday of first day*************************
REM Create the Grid
REM Offby is used to set the first day to the correct day of the week
REM In loop, a square os created for each day, in the right spot.
FOR i% = 1 to DaysInMonth(mon)
Row% = FIX((OFFBY + i)/ 7) + 1 'Row = that day / 7 (7 days in a row of the calENDar)
Col% = ((OFFBY + i) MOD 7) + 1 'Col = That day MOD 7 (Column is like the remainder of the row division)
topedge& = FROMINCHES(0.6 - (row * 0.7))
leftedge& = FROMINCHES( -3.55 + (col * 0.8))
.CreateRectangle topedge, leftedge, (topedge - FROMINCHES(0.6)), leftedge + FROMINCHES(0.7), 0
NEXT i
REM Create the Numbers
REM This is very similar to the grid section
FOR i% = 1 to DaysInMonth(mon)
Row% = FIX((OFFBY + i)/ 7) + 1
Col% = ((OFFBY + i) MOD 7) + 1
bottomedge& = FROMINCHES(0.3 - (row * 0.7))
leftedge& = FROMINCHES( -3.55 + (col * 0.8))
.CreateArtisticText STR(i)
.SetReferencePoint 7
.SetPosition leftedge, bottomedge
NumID(i) = .GetObjectsCDRStaticID()
NEXT i
REM This just makes a colored background instead of white.
.CreateRectangle FROMINCHES(5.5), FROMINCHES(-4.25), FROMINCHES(-5.5), FROMINCHES(4.25), 0
.ApplyUniformFillColor 2, 40, 0, 0, 0
.OrderToBack
END WITHOBJECT
'*********************************Getting Weekday********************************
REM This SUB returns a number which indicates which day of the week a date refers to
REM Basically it uses a MOD command and uses an offset value
SUB getweekday(wkd as date, wkday%)
CONST offset = 4
weektemp& = INT(wkd) + offset
wkday = (weektemp MOD 7) + 1
END SUB
'*********************************Getting Weekday********************************