Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!jarthur!elroy.jpl.nasa.gov!sdd.hp.com!hplabs!hpda!hpcuhb!hpcllla!hpclisp!defaria@hpclapd.HP.COM From: defaria@hpclapd.HP.COM (Andy DeFaria) Newsgroups: comp.lang.pascal Subject: Re: IMPLEMENT "GOTO" ACROSS MODULES IN TURBO PASCAL?? Message-ID: <950050@hpclapd.HP.COM> Date: 7 Jan 91 19:20:54 GMT References: <11647@j.cc.purdue.edu> Organization: Hewlett-Packard Calif. Language Lab Lines: 57 >/ hpclapd:comp.lang.pascal / zhou@brazil.psych.purdue.edu (Albert Zhou) / 12:15 am Jan 4, 1991 / >Here is the problem: > Suppose there is such a structure in the main part of the program: > > repeat > statemetn 1 > statement 2 > . > . > . > statement n > until whatever > > Now I need to write a subroutine to point the program to statement n. >It seems there is no way to do it in turbo pascal, since goto statement >can not go out of a subroutine. Seems pretty simple to me: Function WhereToGo : Integer; Begin If then WhereToGo := 1 else If then WhereToGo := 2 else If then WhereToGo := 3 else WhereToGo := MaxInt; End; { In main code.... } Repeat Case WhereToGo of 1: statement1; 2: statement2; 3: statement3; n: statementn; else WriteLn ('Do not know where to go!'); End; Until whatever; { or maybe... } Repeat JumpIndicator := WhereToGo; Case JumpIndicator of 1: statement1; 2: statement2; 3: statement3; n: statementn; End; Until JumpIndicator = MaxInt;