/*********************************************/ /* */ /* Calendar v1.0 */ /* An AREXX script for Wordworth 5 */ /* By Adam Dawes (Adam@beachyhd.demon.co.uk) */ /* 19th April 1996 */ /* */ /*********************************************/ Options Results /*-- First find the month we're supposed to draw --*/ calmonthname = "" calyear = "" GetMonth: WizardReq TITLE "Calendar v1.0 by Adam Dawes" LABEL "Select month and year for calendar:" TEXTBOX 1 "_Month:" CONTENTS calmonthname TEXTBOX 2 "_Year:" CONTENTS calyear BUTTON 1 "_OK" BUTTON 2 "_This Month" BUTTON "-1" "_Cancel" Pressed = Result if Pressed = -1 then exit sub if Pressed = 2 then do calmonthname = Date("M") calyear = left(Date("S"),4) signal GetMonth end Wizard_GetTextBox 1 calmonthname = Result Wizard_GetTextBox 2 calyear = Result /*-- Now check we have a valid month and year --*/ if calyear < 0 then do RequestNotify "Invalid year: "calyear signal GetMonth end if calyear <100 then calyear = calyear + 1900 if length(calmonthname) > 0 then do /* convert to correct case: Xxxx... */ calmonthname = translate(calmonthname,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ") calmonthname = upper(left(calmonthname,1))||right(calmonthname,length(calmonthname)-1) end calmonth = 0 do monthcheck = 1 to 12 monthtemp = monthcheck if monthtemp < 10 then monthtemp = "0"monthtemp if calmonthname = date("M","1996"monthtemp"01","S") | calmonthname = left(date("M","1996"monthtemp"01","S"),3) then calmonth = monthcheck end if calmonth < 10 then calmonth = "0"calmonth if calmonth = 0 then do RequestNotify "Unrecognised month: "calmonthname signal GetMonth end /*-- Find the first and last date to be drawn on the calendar --*/ startdate = date("I",calyear||calmonth||01,"S") startweekday = date("W",calyear||calmonth||01,"S") calendartitle = date("M",startdate)" "calyear calmonth = calmonth + 1 if calmonth = 13 then do calmonth = 1 calyear = calyear + 1 end if calmonth < 10 then calmonth = "0"calmonth enddate = date("I",calyear||calmonth||01,"S") do daycheck = 0 to 6 daytemp = "0"daycheck+1 if startweekday = date("W","199604"daytemp,"S") then currday = daycheck end /* if startweekday = "Monday" then currday = 0 if startweekday = "Tuesday" then currday = 1 if startweekday = "Wednesday" then currday = 2 if startweekday = "Thursday" then currday = 3 if startweekday = "Friday" then currday = 4 if startweekday = "Saturday" then currday = 5 if startweekday = "Sunday" then currday = 6 */ /*-- Now start drawing the calendar --*/ DrawTextFrame 1 "4cm" "2cm" "7cm" "1cm" "0.0cm" "0.0cm" "0cm" "0cm" TRANSPARENT monthid = Result SelectObject monthid NewParagraph Cursor UP CentreJustify Font NAME "Shannon Book" SIZE "12" Text calendartitle /*-- Draw the day headers --*/ do i = 0 to 6 DrawTextFrame 1 i+4"cm" "3cm" "1cm" "0.8cm" "0.0cm" "0.0cm" "0cm" "0cm" TRANSPARENT titleid.i = Result SelectObject titleid.i NewParagraph Cursor UP CentreJustify Font NAME "Shannon Book" SIZE "9" if i = 0 then Text "Mon" if i = 1 then Text "Tue" if i = 2 then Text "Wed" if i = 3 then Text "Thu" if i = 4 then Text "Fri" if i = 5 then Text "Sat" if i = 6 then Text "Sun" end /*-- Draw the actual days --*/ currdate = startdate dayval = 1 ypos = 3.8 do while currdate < enddate DrawTextFrame 1 currday+4"cm" ypos"cm" "1cm" "0.6cm" "0.1cm" "0.1cm" "0cm" "0cm" TRANSPARENT frameid.dayval = Result SelectObject frameid.dayval NewParagraph Cursor UP CentreJustify Font NAME "Shannon Book" SIZE "11" Text dayval currdate = currdate + 1 dayval = dayval + 1 currday = currday + 1 if currday = 7 then do currday = 0 ypos = ypos + 0.6 end end /*-- Select all the objects we've created, and group them to a single object --*/ SelectObject monthid do i = 0 to 6 SelectObject titleid.i MULTISELECT end currdate = startdate dayval = 1 do while currdate < enddate SelectObject frameid.dayval MULTISELECT dayval = dayval + 1 currdate = currdate + 1 end Group /*-- Finished --*/