Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!cs.umu.se!dvlhma From: dvlhma@cs.umu.se (Henrik Magnusson) Newsgroups: comp.lang.pascal Subject: Re: Overflow error Message-ID: <1991May31.143118.19192@cs.umu.se> Date: 31 May 91 14:31:18 GMT References: <675648024.0@nwark.FidoNet> Sender: news@cs.umu.se (News Administrator) Organization: Dep. of Info.Proc, Umea Univ., Sweden Lines: 52 In article <675648024.0@nwark.FidoNet> Alex.Brown@f1020.n391.z1.FidoNet.Org (Alex Brown) writes: > > I am getting an overflow error after 3 pages are displayed. Can >any tell >why and how to avoid it in the future. > > The program is supposed to grab 24 lines of a text and display them >with a > >>>>>>>MORE<<<<<<<< message at the bottom. [deleted text.] >procedure getstring; > begin > f := 1; > while (not eof(ftext)) and (f < 25) do > begin > readln(ftext, s[f]); > inc(f); > end; > if not eof(ftext) then > begin > s[25] := ' >>>>>>>>MORE<<<<<<<< '; > showpage; > readln; > end; > getstring; > end; > When you are using getstring recurively, you must have a basecondition. Which means you must check if the recursion should stop. I would write getstring like this: PROCEDURE GetString; BEGIN IF (NOT EOF(ftext)) THEN BEGIN : your code here : END END; /NeNNe ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Henrik Magnusson :: "How'd you puncture that tyre?" :: :: dvlhma@cs.umu.se :: "Ran over a milk bottle" :: :: :: "Didn't you see it?" :: :: Umeaa University, Sweden :: "Damn kid had it under his coat." :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::