/*----------------------------------------------------------------------*/ /* (c) Copyright Roger Lacroix 1997 | | | | Designed, developed and programmed by Roger Lacroix | +------------------------------------------------------------------------+ | | | Calendar.REX v1.0 | | | | This is a popup calendar written in Object Rexx for Windows 95/NT. | | | +-----------------------------------------------------------------------*/ trace o '@echo off' /*-----------------------------------------------------------------------+ | First we must initialize all constants, variables and error msg table. | +-----------------------------------------------------------------------*/ CALL InitVariables signal on any name CleanUp /*----------------------+ | Mainline | +----------------------*/ dlg = .Calendar~new(day,month,year,all_months) if dlg~initcode <> 0 then exit dlg~execute("showtop") /* off we go to do some work!! */ dlg~deinstall return /*-----------------------+ | Error exit routine | +-----------------------*/ Cleanup: Beep(200,250) say "Error" rc "occurred at line" sigl":" errortext(rc), || "a"x || condition("o") call ErrorMessage "Error" rc "occurred at line" sigl":" errortext(rc), || "a"x || condition("o")~message EXIT /*------------------------------------------------------------+ | Initialize all constants, msg table and error msg table. | +------------------------------------------------------------*/ InitVariables: year = SUBSTR(DATE('S'),1,4) month = SUBSTR(DATE('S'),5,2) day = SUBSTR(DATE('S'),7,2) yesno = 'YyNn' numbers = '0123456789' all_months = "January February March April May June July August September October November December" RETURN /*----------------------------------------------------------------------------*/ ::requires "oodialog.cls" /*-----------------------------------------------------+ | Generate the monthly report summary (MRS) by hours. | +-----------------------------------------------------*/ ::class Calendar subclass UserDialog ::method Init expose day month year all_months use arg day,month,year,all_months ret = self~init:super; self~InitCode = 0 /* say "inside init" */ ret = self~Load("CALENDAR.RC", 102) if ret = 0 then do self~ConnectList(1101, "SelectedMonth") /* connect button 1101 with a method */ self~ConnectList(1102, "SelectedYear") /* connect button 1102 with a method */ do cb = 1201 to 1242 self~ConnectButton(cb, "ClickButton") end do cb = 1251 to 1256 self~ConnectButton(cb, "ClickButton") end end return 0 ::method InitDialog expose day month year all_months /* say "inside initdialog" */ do i = 1 to 12 self~AddComboEntry(1101, Word(all_months, i)) end self~DropDownMonth = Word(all_months, month) do i = 1981 to 2010 self~AddListEntry(1102, i) end self~YearField = year self~BuildTable() return 0 ::method BuildTable expose day month year all_months /* say "inside BuildTable" */ if (year // 4)=0 & ( (year // 100)<>0 | (year // 400)=0 ) then leap=29 else leap=28 daysinmonth="31 "leap" 31 30 31 30 31 31 30 31 30 31" a1 =(year-1) % 4 /* quotient only - # of leap years */ a2 =(year-1) % 100 /* quotient only - # of centuries years */ a3 =(year-1) % 400 /* quotient only - # of leap centuries years */ totaldays = year+1+a1-a2+a3 /* number of days up to this year */ do cnt = 1 to month-1 /* include days of months in current year */ totaldays = totaldays + word(daysinmonth,cnt) end startingpos=(totaldays+6) // 7 days = word(daysinmonth,month) /* # of days in the month */ do i=1 to startingpos /* clear the beginning numbers */ self~SetValue(1200+i," ") end do i=1 to days self~SetValue(1200+startingpos+i,i) end do i=(startingpos + days + 1) to 42 /* clear the ending numbers */ self~SetValue(1200+i," ") end return 0 ::method ClickButton expose day month year all_months /* call InfoMessage "you click a button!!!" */ return 0 ::method SelectedMonth expose day month year all_months /* say "inside SelectedMonth" */ index = self~GetCurrentComboIndex(1101) month = RIGHT(index,2,'0') self~BuildTable() return 0 ::method SelectedYear expose day month year all_months /* say "inside SelectedYear" */ year = 1980 + self~GetCurrentListIndex(1102) self~BuildTable() return 0