aUCBLogo Demos and Tests / cheetah_dr_test
to cheetah_dr_test
; Example for usage of the free cheetah2.dll database DLL
init
pr " pr [DATE ROUTINES THAT WORK WITH CHEETAH DATES] pr "
local [datecheck datefrom datestring dateto days
juliannumber month pbdate startdate xdate year]
cheetah_dateroutines
(pr [Version:] dr_xdbVersion) pr "
pr "
DateFrom = "19620430
DateTo = "20060218
pr dr_xdbDaysApart DateFrom DateTo
Year = 2007
print dr_xdbDaysInMonth 2007 2
repeat 12 [ Month = repcount type word dr_xdbDaysInMonth Year Month char 32]
pr " pr "
StartDate = "20000723
Days = 2036
print dr_xdbAddDate StartDate Days
StartDate = "20060218
Days = -2036
print dr_xdbAddDate StartDate Days
DateCheck = "20000723
pr dr_xdbNameOfDay DateCheck
DateCheck = "02-18-2006
pr dr_xdbNameOfDay DateCheck
pr dr_xdbTodaysDate
pr dr_xdbValidDate DateCheck
DateString = "20060218
pr dr_xdbDateToJulian DateString
JulianNumber = dr_xdbDateToJulian DateString
pr dr_xdbJulianToDate JulianNumber
PBDate = "02-18-2006 ; MM-DD-YYYY
pr dr_xdbCTOD PBDate
xDate = dr_xdbCTOD PBDate ; YYYYMMDD
pr dr_xdbDTOS xDate
pr " calendar
pr " pr "Finished.
end
to init
TextScreen
clearText
end
be calendar ; Year
local [weekdays months]
weekdays = [Monday Tuesday Wednesday Thursday Friday Saturday Sunday]
months = [January February March April May June July August September October November December]
calendar2_m "2007 lnul 2 ; month
pr " pr "---
calendar2_y "2007 ; year
be calendar2_y :Year
repeat 12 [calendar2_m :Year lnul repcount pr " pr "]
end
be calendar2_m :Year :Month
local [nday wdi dim r]
(pr "Month :Month ": item :Month :months :Year)
nday = dr_xdbNameOfDay (word :Year :Month "01)
wdi = weekdays_idx :nday :weekdays
dim = dr_xdbDaysInMonth :Year :Month
type chain char 32 (:wdi-1)*6
type (word "01 "_ first :nday item 2 :nday char 32)
if 7 == weekdays_idx :nday :weekdays [pr "]
repeat :dim-1 [r = repcount+1
nday = dr_xdbNameOfDay (word :Year :Month lnul :r)
type (word lnul :r "_ first :nday item 2 :nday char 32)
if 7 == weekdays_idx :nday :weekdays [pr "]
]
end
end
to lnul :v
ifelse :v<10 [op word "0 :v][op :v]
end
to chain :ding :times
local [a] a=" repeat :times [make "a word :a :ding] op :a
end
to weekdays_idx :day :weekdays
if emptyp :weekdays [pr "Error stop]
if :day == last :weekdays [op count :weekdays]
op weekdays_idx :day butlast :weekdays
end