Re: Calculate Easter's Date
Posted in 1996
loudelon@vianet.on.ca (Louis DeLongchamp) wrote: >Found this (Pascal?) code to calculate Easter's date. How would this >look in 4gl? What is rem? > > integer year, a, b, c, d, e, x, y, t ; > cut short rem is the remainder of a division. 4gl calls it a modulus and uses the mod function. Here's the Pascal code written in 4GL: # Figure out Easter date for given year main define a, b, c, d, e, x, y, t integer, aMonth, aYear integer, easterDate date while true prompt "Which year (Enter 0 to stop) ? " for aYear if aYear = 0 then exit while end if let a = rem (aYear, 19) let b = rem (aYear, 4) let c = rem (aYear, 7) case when aYear < 1700 display "Year too small" ; continue while when aYear < 1800 let x = 23 ; let y = 3 when aYear < 1900 let x = 23 ; let y = 4 when aYear < 2100 let x = 24 ; let y = 5 when aYear < 2200 let x = 24 ; let y = 6 when aYear < 2300 let x = 25 ; let y = 0 otherwise display "Year too large" ; continue while end case let d = rem (19 * a + x, 30) let e = rem (2 * b + 4 * c + 6 * d + y, 7) let t = d + e + 22 if t <= 31 then let aMonth = 3 # March 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 let aMonth = 4 # April end if let easterDate = mdy(aMonth,t,aYear) display "Easter is on ", easterDate using "mmm dd, yyyy" end while end main function rem(a,b) # Figure out remainder define a,b,c integer let c = a mod b return c end function Catalin. -- ========================================================================= Catalin Badea _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/ _/ _/ _/ _/ _/_/ _/ Senior Technical Architect _/ _/_/ _/ _/_/_/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ Tecsys Inc. _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/_/ ===== cat@tecsys.com =========== include system "disclaimer.4gh" ===== == http://www.virtualmarketplace.com/LEVEL3/ITEC/TECSYSE/TECSYSE.HP ===