Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!psuvax1!rutgers!mcnc!uvaarpa!murdoch.acc.virginia.edu!sasha.acc.Virginia.EDU!scl From: scl@sasha.acc.Virginia.EDU (Steve Losen) Newsgroups: comp.lang.pascal Subject: Re: exiting some calling ancestor in Turbo Pascal 5 Message-ID: <1989Dec18.132328.6049@murdoch.acc.Virginia.EDU> Date: 18 Dec 89 13:23:28 GMT References: <122@crucible.UUCP> <8912141752.aa23459@ICS.UCI.EDU> Sender: news@murdoch.acc.Virginia.EDU Reply-To: scl@sasha.acc.Virginia.EDU (Steve Losen) Organization: University of Virginia Lines: 29 In article <8912141752.aa23459@ICS.UCI.EDU> milne@ICS.UCI.EDU (Alastair Milne) writes [description of need for multi-level "EXIT" deleted....] > Turbo Pascal gives only, as far as I know, EXIT (which exits the immediate > block, but nothing further) and HALT (which kills the whole program). > Does anybody know of a way in Turbo Pascal to obtain the effect of UCSD Doesn't turbo allow non-local gotos, which are in the current ISO standard and have been a Pascal feature since the beginning? You can declare a label in an outer block and jump to it from an inner block. This terminates the activation of the inner block and all intervening activations back to the most recent activation of the outer block. Execution of the outer block resumes at the goto target label. This may not be as flexible as the UCSD exit. You can only non-locally goto a block that encloses the current block. Furthermore, the target statement must be at the outermost nesting level of the block (eg, you cannot jump into a "for", "while", "if", etc. statement.). For years folks have used this for emergency error termination. You declare a label in the main program and place it near the final "end.". Any block that hasn't redeclared the label can jump back to the main program for a clean exit. You could also use this technique in a deeply nested menu driven application to jump back to the code that displays top of the main menu. Steve Losen scl@virginia.edu University of Virginia Academic Computing Center