Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!mentor.cc.purdue.edu!j.cc.purdue.edu!brazil.psych.purdue.edu!zhou From: zhou@brazil.psych.purdue.edu (Albert Zhou) Newsgroups: comp.lang.pascal Subject: Re: IMPLEMENT GOTO ACROSS MODULES IN TURBO PASCAL?? Message-ID: <11656@j.cc.purdue.edu> Date: 6 Jan 91 03:53:45 GMT References: <25404@adm.brl.mil> Sender: news@j.cc.purdue.edu Reply-To: zhou@brazil.psych.purdue.edu (Albert Zhou) Organization: Purdue University Lines: 58 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: > >var > flag_val : byte; >... > flag_val := 0; > repeat > if flag_val <= 1 then statement1; > if flag_val <= 2 then statement2; > ... > if flag_val <= n then statementn; > flag_val := 0; > until whatever; > >(Note that appropriate manipulation of flag_val allows statementI to >cause a skip of a range of following statements I+1..n.) 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.