home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
DOS
/
TEKST
/
AURORA2
/
CALENDAR.AML
< prev
next >
Wrap
Text File
|
1995-04-28
|
5KB
|
170 lines
/* ------------------------------------------------------------------ */
/* Macro: CALENDAR.AML */
/* Written by: nuText Systems */
/* */
/* Description: This macro displays a popup calendar window for the */
/* current year and month. */
/* */
/* Usage: You can move to other months and years with the */
/* following keys: */
/* */
/* <pgdn> - next month */
/* <pgup> - prev month */
/* <right> - same month, next year */
/* <left> - same month, prev year */
/* <ctrl pgdn> - december of the current year */
/* <ctrl pgup> - january of the current year */
/* <esc> - exit the calendar */
/* ------------------------------------------------------------------ */
include bootpath "define.aml"
// define the colors to use
define
set cal_client_color color black on gray
set cal_border_color color white on gray
set cal_title_color color brightblue on gray
set cal_today_color color brightgreen on gray
set cal_control_color color yellow
end
// function to redraw the calendar for any year and month
function draw (year month)
var monthdays
// set the calendar title based on the year and month
settitle (case month
when 1 "January" when 7 "July"
when 2 "February" when 8 "August"
when 3 "March" when 9 "September"
when 4 "April" when 10 "October"
when 5 "May" when 11 "November"
when 6 "June" when 12 "December"
end) + " " + year 'c'
// get the day in which the year starts using a perpetual
// calendar (0-6, 0=sunday)
startday = "5012356013456123460124560234" [year mod 28 + 1]
// string indicating the days over 28 for each month
over28 = concat (if? (not (year mod 4)) "31" "30") "3232332323"
// get total days in the month
maxdays = 28 + over28 [month]
// get the number of days in previous months
i = 1
while i < month do
monthdays = monthdays + 28 + over28 [i]
i = i + 1
end
// calculate the starting day for the month (0-6, 0=sunday)
startday = (startday + monthdays) mod 7
// set 'today' to today's day number if it's the right
// year and month
rawtime = getrawtime
today = if rawtime [5:2] == month and rawtime [1:4] == year then
rawtime [7:2]
end
// clear the window and draw the header
clearwindow color cal_client_color
gotoxy 1 1
writeline " Sun Mon Tue Wed Thu Fri Sat " (color cal_title_color)
// move the video cursor to the start-day position
gotoxy 2 + startday * 5
// write the calendar days
day = 1
while day <= maxdays do
writestr (pad day 3) + " "
(if? day == today cal_today_color cal_client_color)
if getx > 34 then
writeline
writestr ' '
end
day = day + 1
end
end
// create the calendar window
createwindow
setwinobj
setframe ">b"
setwinctrl '≡'
setshadow 2 1
sizewindow 36 5 71 11 "ad"
setborder "1i"
setcolor border_color cal_border_color
setcolor text_color cal_client_color
setcolor control_color cal_control_color
// current year and month
year = getrawtime [1:4]
month = getrawtime [5:2]
loop
// redraw the calendar window
draw year month
case getkey
when <esc>
break
// mouse click
when <button>
case getregion
// close icon
when 51
break
end
// forward one month
when <pgdn>
month = month + 1
if month > 12 then
month = 1
year = year + 1
end
// backward one month
when <pgup>
month = month - 1
if not month then
month = 12
year = year - 1
end
// goto january
when <ctrl pgup>
month = 1
// goto december
when <ctrl pgdn>
month = 12
// forward one year
when <right>
year = year + 1
// backward one year
when <left>
if year then
year = year - 1
end
end
end
// destroy the calendar window
destroywindow