Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!utrcu1!infnews!infnews!devisser From: devisser@cs.utwente.nl (Jan de Visser) Newsgroups: comp.lang.pascal Subject: Re: Gotos are ok (Was Re: IMPLEMENT GOTO ACROSS MODULES IN TURBO PASCAL??) Message-ID: <1991Jan21.134342@cs.utwente.nl> Date: 21 Jan 91 12:43:42 GMT References: <1991Jan10.122222.1013@uwasa.fi> <1991Jan16.005523.28337@syacus.acus.oz> <7612@plains.NoDak.edu> <2802@oucsace.cs.OHIOU.EDU> Sender: usenet@cs.utwente.nl Reply-To: devisser@cs.utwente.nl (Jan de Visser) Organization: University of Twente, Dept. of Computer Science Lines: 33 In article <2802@oucsace.cs.OHIOU.EDU>, tswingle@oucsace.cs.OHIOU.EDU (Tom Swingle) writes: |> Here is a situation where I found a goto to be the neatest, easiest way to |> solve a problem. I had a procedure with nested repeat loops, at least two |> deep. I wanted to break out of the procedure if an error occured, but first |> there were things that had to be done (restoring screen, closing files, etc.) |> before I could leave the procedure. These things needed to be done with either |> normal or abnormal termination of the procedure, and its code was several lines |> long. Normally, it would be done at the end of the procedure (logical, right?) |> but if I needed to get out immediately, I needed a way to execute this code and |> leave. Here's a skeleton of the procedure: |> |> [much deleted] How about: placing your 'exit-code' in a 'local' procedure, called, say, ExitProc, and use the following code in case of an error: IF THEN BEGIN ExitProc; Exit END; No gotos! Jan. Disclaimer: I know nothing, I'm from Barcelona!