// Function : InFreq // Purpose : Returns zero if date is within frequence, otherwise returns number of days to next // occurence of frequence Function InFreq Global Date dDate Date dStart Integer iType Integer iFrequence Integer iExtra Returns Integer Integer iDays iWeeks iMonths iYears Integer iDay iFrom iTo // Daily If (iType = 0) Begin Move (dDate-dStart) To iDays If (Mod(iDays,iFrequence) = 0) Function_Return 1 End // If (iType = 0) Begin // Weekly If (iType = 1) Begin // Monday is set to be first day of week Move (DayOfWeek(ghoDateHandler,dDate)) To iDay Move ((dDate-iDay) - (dStart-DayOfWeek(ghoDateHandler,dStart)) / 7) To iWeeks If (Mod(iWeeks,iFrequence) = 0) Begin If (iDay = 0 And iExtra iAnd $00000001) Function_Return 1 If (iDay = 1 And iExtra iAnd $00000002) Function_Return 1 If (iDay = 2 And iExtra iAnd $00000004) Function_Return 1 If (iDay = 3 And iExtra iAnd $00000008) Function_Return 1 If (iDay = 4 And iExtra iAnd $00000010) Function_Return 1 If (iDay = 5 And iExtra iAnd $00000020) Function_Return 1 If (iDay = 6 And iExtra iAnd $00000040) Function_Return 1 End // If (Mod(iWeeks,iFrequence) = 0) Begin End // If (iType = 1) Begin // Monthly If (iType = 2) Begin If (iExtra iAnd $80000000) Begin // Nth Weekday of every N month(s) If (DayOfWeek(ghoDateHandler,dDate)*256 = iExtra iAnd $0000FF00) Begin // Calculate weekday of first day of month Move (YearFromDate(ghoDateHandler,dDate)) To iYears Move (MonthFromDate(ghoDateHandler,dDate)) To iMonths If (iExtra iAnd $000000FF <> 4) Begin Move (DayOfWeek(ghoDateHandler,ComposeDate(ghoDateHandler,iYears,iMonths,1))) To iDay // Calculate difference in days Move ((iExtra iAnd $0000FF00/256) - iDay) To iDays If (iDay > (iExtra iAnd $0000FF00/256)) Move (iDays+7) To iDays Move (iDays + (iExtra iAnd $000000FF * 7)) To iDays If (ComposeDate(ghoDateHandler,YearFromDate(ghoDateHandler,dDate),MonthFromDate(ghoDateHandler,dDate),iDays+1) <> dDate) Function_Return 0 End // If (iExtra iAnd $000000FF <> 4) Begin If (iExtra iAnd $000000FF = 4) Begin Move (DayOfWeek(ghoDateHandler,LastMonthDayDate(ghoDateHandler,iYears,iMonths))) To iDay // Calculate difference in days Move ((iExtra iAnd $0000FF00/256) + iDay) To iDays If (iDay < (iExtra iAnd $0000FF00/256)) Move (iDays-7) To iDays If (LastMonthDayDate(ghoDateHandler,iYears,iMonths)-iDays <> dDate) Function_Return 0 End // If (iExtra iAnd $000000FF = 4) Begin // Check frequence Move (YearFromDate(ghoDateHandler,dStart)) To iFrom Move (YearFromDate(ghoDateHandler,dDate)) To iTo Move (iTo-iFrom*12) To iMonths Move (iMonths + (MonthFromDate(ghoDateHandler,dDate) - MonthFromDate(ghoDateHandler,dStart))) To iMonths If (Mod(iMonths,iFrequence) = 0) Function_Return 1 End // If (DayOfWeek(ghoDateHandler,dDate)*256 = iExtra iAnd $0000FF00) Begin End // If (iExtra iAnd $00000008) Begin Else Begin // Every Nth day of every N month(s) If (DayFromDate(ghoDateHandler,dDate) = iExtra) Begin Move (YearFromDate(ghoDateHandler,dStart)) To iFrom Move (YearFromDate(ghoDateHandler,dDate)) To iTo Move (iTo-iFrom*12) To iMonths Move (iMonths + (MonthFromDate(ghoDateHandler,dDate) - MonthFromDate(ghoDateHandler,dStart))) To iMonths If (Mod(iMonths,iFrequence) = 0) Function_Return 1 End // If (DayFromDate(ghoDateHandler,dDate) = iExtra) Begin End // Else Begin End // If (iType = 2) Begin // Yearly If (iType = 3) Begin If (iExtra iAnd $80000000) Begin // Nth Weekday of Nth month of every N year(s) If (DayOfWeek(ghoDateHandler,dDate)*256 = (iExtra iAnd $0000FF00)) Begin // Calculate weekday of first day of month Move (YearFromDate(ghoDateHandler,dDate)) To iYears Move (MonthFromDate(ghoDateHandler,dDate)) To iMonths // Check month If (iMonths <> (iExtra iAnd $00FF0000/65536+1)) Function_Return 0 If (iExtra iAnd $000000FF <> 4) Begin Move (DayOfWeek(ghoDateHandler,ComposeDate(ghoDateHandler,iYears,iMonths,1))) To iDay // Calculate difference in days Move ((iExtra iAnd $0000FF00/256) - iDay) To iDays If (iDay > (iExtra iAnd $0000FF00/256)) Move (iDays+7) To iDays Move (iDays + (iExtra iAnd $000000FF * 7)) To iDays If (ComposeDate(ghoDateHandler,iYears,iMonths,iDays+1) <> dDate) Function_Return 0 End // If (iExtra iAnd $000000FF <> 4) Begin If (iExtra iAnd $000000FF = 4) Begin Move (DayOfWeek(ghoDateHandler,LastMonthDayDate(ghoDateHandler,iYears,iMonths))) To iDay // Calculate diffence in days Move ((iExtra iAnd $0000FF00/256) + iDay) To iDays If (iDay < (iExtra iAnd $0000FF00/256)) Move (iDays-7) To iDays If (LastMonthDayDate(ghoDateHandler,iYears,iMonths)-iDays <> dDate) Function_Return 0 End // If (iExtra iAnd $000000FF = 4) Begin // Check frequence Move (YearFromDate(ghoDateHandler,dStart)) To iFrom Move (YearFromDate(ghoDateHandler,dDate)) To iTo If (Mod(iTo-iFrom,iFrequence) = 0) Function_Return 1 End // If (DayOfWeek(ghoDateHandler,dDate)*256 = iExtra iAnd $0000FF00) Begin End // If (iExtra iAnd $80000000) Begin Else Begin // Every Nth day of Nth month of every N year(s) If (DayFromDate(ghoDateHandler,dDate) = iExtra) Begin If (MonthFromDate(ghoDateHandler,dDate) <> (iExtra iAnd $0000FF00 + 1)) Function_Return 0 Move (YearFromDate(ghoDateHandler,dStart)) To iFrom Move (YearFromDate(ghoDateHandler,dDate)) To iTo If (Mod(iTo-iFrom,iFrequence) = 0) Function_Return 1 End // If (DayFromDate(ghoDateHandler,dDate) = iExtra) Begin End // Else Begin End // If (iType = 3) Begin End_Function // InFreq