Re: Calculate Easter's Date
Posted in 1996
> > Found this (Pascal?) code to calculate Easter's date. How would this > look in 4gl? What is rem? The Rem looks like a MOD, which is odd since Pascal has a MOD. inint and outtext are not standard Pascal - although their purpose is evident. DEFINE YR, a, b, c, d, e, x, y, t INTEGER PROMPT "Which year (Enter 0 to stop) ? " FOR YR WHILE YR != 0 LET a = YR MOD 19 LET b = YR MOD 4 LET c = YR MOD 7 CASE WHEN YR < 1700 ERROR "Year to small" WHEN YR < 1800 LET x = 23 LET y = 3 WHEN YR < 1900 LET x = 23 LET y = 4 WHEN YR < 2100 LET x = 24 LET y = 5 WHEN YR < 2200 LET x = 24 LET y = 6 WHEN YR < 2300 LET x = 25 LET y = 0 OTHERWISE error "Annee trop grande" #error "Year to big" END CASE LET d = (19 * a + x) MOD 30 LET e = (2 * b + 4 * c + 6 * d + y) MOD 7 LET t = d + e + 22 DISPLAY "In ", YR IF t < 31 THEN DISPLAY "Easter is on March ", t ELSE LET t = t - 31 IF t = 26 THEN LET t = 19 END IF IF t = 25 AND d = 28 AND e = 6 AND a > 10 THEN LET t = 18 END IF DISPLAY "Easter is on April ", t END IF PROMPT "Which year (Enter 0 to stop) ? " FOR YR END WHILE Just tried this for 1996 - it gave the right answer. Thanks, I haven't done Pascal for ages. cheers j. > > integer year, a, b, c, d, e, x, y, t ; > outtext ("Which year (Enter 0 to stop) ? ") ; > breakoutimage ; > year := inint ; > while year <> 0 do begin > a := rem (year, 19) ; > b := rem (year, 4) ; > c := rem (year, 7) ; > if year < 1700 then error ("Year too small") > else if year < 1800 then begin x := 23 ; y := 3 end > else if year < 1900 then begin x := 23 ; y := 4 end > else if year < 2100 then begin x := 24 ; y := 5 end > else if year < 2200 then begin x := 24 ; y := 6 end > else if year < 2300 then begin x := 25 ; y := 0 end > else error ("Annee trop grande") ; > d := rem (19 * a + x, 30) ; > e := rem (2 * b + 4 * c + 6 * d + y, 7) ; > t := d + e + 22 ; > outtext ("In ") ; outint (year, 0) ; > outtext (" Easter is on ") ; > if t <= 31 then begin > outint (t, 0) ; outtext (" March") > end > else begin > t := t - 31 ; > if t = 26 then t := 19 ; > if t = 25 and d = 28 and e = 6 and a > 10 > then t := 18 ; > outint (t, 0) ; outtext (" April") > end ; > outimage ; outimage ; > outtext ("Which year ? ") ; > breakoutimage ; > year := inint > end > end > > Louis DeLongchamp > loudelon@ViaNet.on.ca > > _____________________________________________________________________________ Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA jparker@hpbs3645.boi.hp.com _____________________________________________________________________________ If anything can go wrong, fix it. To hell with Murphy. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________