home *** CD-ROM | disk | FTP | other *** search
- /* A Final Writer Macro to draw monthly calendars */
- /* Written by William Barnes 4/95 */
- /* */
- /* INTRO */
- /* This is my first attempt at writing a program */
- /* in ARexx. The script will draw a calendar using */
- /* text blocks and boxes and group them into 1 giant */
- /* object that can be moved and resized as desired. */
- /* */
- /* USAGE: Just run the script from withing Final */
- /* Writer. The script will ask you for the */
- /* month and the year and generate the */
- /* calendar. */
- /* */
- /* NOTE: The 3 lines containing the font paths will */
- /* most likely need to be changed to fit your */
- /* system. */
- /* */
- /* TECHNICAL (?) */
- /* The code could probably be written */
- /* more efficiently, but once I got it to work */
- /* I didn't want to mess anything up. So far, it */
- /* accurately generates calendars for 1995 and 1996. */
- /* I set the limit on the years from 1900 - 2050 */
- /* because I'm not sure how accurate the algorithm */
- /* to determine the day of the week is. I don't */
- /* think many people need monthly calendars for the */
- /* 1800's anyways. Feel free to change the limits */
- /* if you need to. */
- /* */
- /* HISTORY */
- /* I saw a similar macro being used on Wordperfect */
- /* 6.0 on a 486 laptop. I'm not sure why, but it */
- /* was pretty slow. Since I don't have an IBM and */
- /* I couldn't find anything similar for the Amiga */
- /* I decided to try and do it myself. */
- /* */
- /* FUTURE IMPROVEMENTS */
- /* An event list manager. I think that this is */
- /* beyond the scope of a simple macro as well as */
- /* way beyond my programming abilities. Maybe */
- /* some day.... */
- /* */
- /* BUGS, COMMENTS, ETC.. */
- /* This program is released as freeware. Feel free */
- /* to do whatever you like with it. If you like it, */
- /* or have any comments about it,, feel free to let */
- /* me know. If there are any ARexx commandos out */
- /* there who would like to show me how I could improve */
- /* my programming skills feel please send me some input.*/
- /* */
- /* I can be contacted at: */
- /* */
- /* CompuServe: 73060,65 */
- /* InterNet: 73060.65@Compuserve.com */
- /* */
- /* THANKS */
- /* I'd like to thank Russell Solub and Eduard Joseph */
- /* for their programming advice and SoftWood for a */
- /* great program and generous upgrade policy. */
-
-
- Options Results
-
- /*********** These are the paths for the fonts to be used *************/
- /*********** and will probably need to be changed to fit *************/
- /*********** your system. *************/
-
- TitleFont = "dh1:finalwriter/fwfonts/swolfonts/serif/Clearface_bolditalic"
- DaysOfWeekFont = "dh1:finalwriter/fwfonts/swolfonts/serif/valencia_bolditalic"
- DayNumberFont = "dh1:finalwriter/fwfonts/swolfonts/serif/valencia_bolditalic"
-
- /*****************************************************************************/
-
- monthtext = "January February March April May June July August September October November December"
- daystring = "31 28 31 30 31 30 31 31 30 31 30 31"
-
- SetMeasure inches
- ClearDoc Force
- DisplayPrefs Rulers none
- BoxPrefs TEXTFLOW None LINEWT 1 FILL Transparent
- TextBlockPrefs TextFlow None
-
- /*********** Get month to be printed **************/
- valid = 0
- do while valid = 0
- RequestText '"Enter Month" "Month number to be printed (1 - 12)" ""'
- month = Result
- if DATATYPE(month,Numeric) = 1
- then
- if ((month >= 1) & (month <= 12))
- then
- valid = 1
- else NOP
- else NOP
- end
- mo = SUBWORD(monthtext,month,1)
-
- /*********** Get year to be printed *************/
- valid = 0
- do while valid = 0
- RequestText '"Enter Year" "Year to be printed (1900 - 2050)" ""'
- year = Result
- if DATATYPE(year,Numeric) = 1
- then
- if ((year >= 1900) & (year <= 2050))
- then
- valid = 1
- else NOP
- else NOP
- end
-
- /******** Determine # of days in the month (corrected for leapyear *******/
- if ( (year // 4 = 0) & (year // 100 ~= 0) | (year // 400 = 0) )
- then
- leapyear = 1
- else
- leapyear = 0
- days = SUBWORD(daystring,month,1)
- if month = 2
- then days = days + leapyear
-
- /***** Calculate 1st day of the week for the desired month *****/
- realyear = year
- if month < 3 then do
- year = year - 1
- month = month + 13
- end
- else do
- month = month + 1
- end
- n = (1461 * year)%4 + (153 * month)%5 + 1
- index = ((n - 621049)//7)
-
- /******* Draw and center title *********/
- TextBlockTypePrefs Size 45 Font TitleFont
- mo = mo realyear
- DrawTextBlock 1 .75 .75 mo
- obnum = Result
- GetObjectCoords obnum
- coords = Result
- PARSE VAR coords page left top width height
- newleft = 4 - (width / 2)
- SetObjectCoords obnum 1 newleft top width height
- redraw
-
- /****** Draw days of week and boxes around them *****/
- TextBlockTypePrefs Size 10 Font DaysOfWeekFont
- DrawTextBlock 1 .625 1.625 "Sunday"
- DrawTextBlock 1 1.625 1.625 "Monday"
- DrawTextBlock 1 2.625 1.625 "Tuesday"
- DrawTextBlock 1 3.625 1.625 "Wednesday"
- DrawTextBlock 1 4.625 1.625 "Thursday"
- DrawTextBlock 1 5.625 1.625 "Friday"
- DrawTextBlock 1 6.625 1.625 "Saturday"
-
- DrawBox 1 .5 1.5 1 .375
- DrawBox 1 1.5 1.5 1 .375
- DrawBox 1 2.5 1.5 1 .375
- DrawBox 1 3.5 1.5 1 .375
- DrawBox 1 4.5 1.5 1 .375
- DrawBox 1 5.5 1.5 1 .375
- DrawBox 1 6.5 1.5 1 .375
- redraw
-
- /****** Draw days of month boxes ******/
- TextBlockTypePrefs Size 20 Font DayNumberFont
- boxheight = 1.5
- if days + index > 35
- then boxheight = 1.25
-
- do loop = 1 to days
- grid = loop + index
- left = grid - (( (grid - 1) % 7) * 7) - .5
- top = ((grid - 1) % 7) * boxheight + 2
- top1 = .125 + top /** offset for day # textblock **/
- left1 = .125 + left /** offset for day # textblock **/
- DrawBox 1 left top 1 boxheight
- DrawTextBlock 1 left1 top1 loop
- obnum = Result
- redraw
- end
-
- /******* Select all objects and group them into 1 object *******/
- do loop = 1 to obnum
- SelectObject loop Multiple
- end
- Group
-
- SelectObject 0
- exit
-