Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekgen!penguin.uss.tek.com!decomyn From: decomyn@penguin.uss.tek.com Newsgroups: comp.lang.pascal Subject: Re: IMPLEMENT GOTO ACROSS MODULES IN TURBO PASCAL?? Message-ID: <7147@tekgen.BV.TEK.COM> Date: 7 Jan 91 00:56:41 GMT References: <25404@adm.brl.mil> <11656@j.cc.purdue.edu> Sender: news@tekgen.BV.TEK.COM Reply-To: decomyn@penguin.uss.tek.com (Vergil William de Comyn) Organization: Tektronix, Inc., Beaverton, OR. Lines: 96 In article <11656@j.cc.purdue.edu> zhou@brazil.psych.purdue.edu (Albert Zhou) writes: >In article <25404@adm.brl.mil> CDCKAB%EMUVM1.BITNET@cunyvm.cuny.edu ( Karl Brendel) writes: >>In article <11647@j.cc.purdue.edu>, zhou@brazil.psych.purdue.edu >> (Albert Zhou) wrote: >> >>Try reworking your repeat statement so that each statement 1..n has >>an associated value. Set that value in the subroutine(s). The loop >>would look something like: [code example deleted] > >However, this only works when the error arises at the second level of the >structure (suppose the repeat-until statement is at the first level). If >the error arises at a deeper level, it will be a long way before going to >statement n at the first level. Consider the following example: > > statement 2 calls proc1, > procedure proc1; > begin > ... > proc2; > ... > end; > > procedure proc2; > begin > ... > proc3; > ... > end; > > procedure proc3; > begin > ... > { this statement might cause error so I insert the error processing > you suggested} > if an error then begin > val_flage = n; > exit; > end; > ... > end; > > So when the error comes up, it will continue to finish proc2 and >proc1 before returning to the first level. But any attemp to continue the >execution of proc2 and proc1 after an error arises will cause problem. The solution is to test the value of val_flage after each call. In fact, if a procedure might be called from more than one statement, you can easily test for a change in the flag. Using your sample as a base, you could try: statement 2 calls proc1, procedure proc1; var Save_val : flage; { assumes type "flage" defined earlier } begin ... Save_val:=val_flage; proc2; if Save_Val<>val_flage then Exit ... end; procedure proc2; var Save_val : flage; { assumes type "flage" defined earlier } begin ... Save_val:=val_flage; proc3; if Save_Val<>val_flage then Exit ... end; procedure proc3; var begin ... { this statement might cause error so I insert the error processing you suggested} if an error then begin val_flage = n; exit; end; ... end; Clear enough? ------------------------------------------------------------------------------- Brendt Hess a.k.a. | Disclaimer: Opinions? I don't even work here! Vergil William de Comyn a.k.a. |----------------------------------------------- Payne Hirds | Life is not a zero-sum game: decomyn@penguin.uss.tek.com | don't treat it as such.