Calendar
FlexibleLearning at aol.com
FlexibleLearning at aol.com
Tue Aug 2 12:40:53 CDT 2005
>Does anybody have [and willing to share] a calendar maker?
>
>Thanks,
>
>Ray Horsley
>Developer, LinkIt! Software
>From ssBk:
on mouseUp
# Syntax: FLCcalendar (<startDay 1-7>, <Month 1-12>,<Year 1970-2037>)
# Gives a language-localized calendar with selectable first day of week
put random(7) into weekStartsOn
put random(12) into tMonth
put random(67) +1969 into tYear
put FLCcalendar(weekStartsOn,tMonth,tYear) into cd fld "Calendar"
end mouseUp
function FLCcalendar tStartDayNum,tM,tY
put the system monthNames into tMonthNames
get the abbrev system WeekDayNames
repeat for each line L in it
if len(L) is 2 then put space & L into L
put char 1 to 3 of L &cr after tAbbrevWeekDayNames
end repeat
delete last char of tAbbrevWeekDayNames
# Verify params...
put tM &"/1/"& tY into tCalendarMonth
convert tCalendarMonth to dateItems
if the result <>"" then return "Date error"
put item 1 of tCalendarMonth into tY
# Build Calendar title...
put line (item 2 of tCalendarMonth) of tMonthNames && tY into monthHeader
# Build Calendar day header line, starting from selected day of the week...
put tAbbrevWeekDayNames into dayHeader
put (line tStartDayNum to -1 of dayHeader)&cr&(line 1 to tStartDayNum -1 of
dayHeader) into dayHeader
replace cr with space in dayHeader
# To centre the monthHeader...
put char 1 to round((length(dayHeader)-length(monthHeader)) div 2) +1 of "
" before monthHeader
# Build Calendar...
put empty into days
if tStartDayNum is 1 then put 7 into tEndDayNum
else put tStartDayNum -1 into tEndDayNum
# Calculate position of first date...
put (item 7 of tCalendarMonth) - (tStartDayNum)+1 into dayOffset
if dayOffset < 1 then put (7+ dayOffset) into dayOffset
repeat with dayNum = 1 to dayOffset -1
put " " after days
end repeat
# Complete Calendar...
repeat while item 2 of tCalendarMonth is tM
get " " & item 3 of tCalendarMonth & " "
if length(it) is 3 then get " " & it
if item 7 of tCalendarMonth is tEndDayNum then get it & cr
put it after days
add 1 to item 3 of tCalendarMonth
convert tCalendarMonth from dateItems to long system date -- to force next
line to update
convert tCalendarMonth from long system date to dateItems
end repeat
return monthHeader & cr & dayHeader & cr & days
end FLCcalendar
/H
More information about the metacard
mailing list