I've often wished for some sort of block syntax in basic as well. Usually I use LOOP with an exit, like you do, or a gosub, but when I migrate code to Cache mvbasic there is a nice construct--the TRY/CATCH block:
TRY block code block code if condition then THROW exception block code if condition then ABORT block code block code CATCH excpt if excpt->Name="<MV WRAPUP> then abort END TRY Your code can throw different kinds of exceptions that you can either test for or ignore in the CATCH section (the basic ABORT command actually throws an <MV WRAPUP> exception, and in the example I test for that and propagate the abort, but just ignore the other exception) On Feb 7, 2011, at 3:25 PM, George Gallen wrote: > I want to setup a block of commands, and be able to exit out of the block if > needed. > Right now I use a LOOP/REPEAT with an EXIT statement before the REPEAT. > I'd rather not use labels (or subroutines). > The Loop/Repeat works, it just looks weird since it isn't really a loop... > I tried using an IF block, but I couldn't use the EXIT within that block IF > (1=1) THEN..........END > > LOOP > block code > block code > if condition then EXIT > block code > EXIT > REPEAT > > Would be nice if.... > > BEGIN BLOCK > block code > block code > if condition then EXIT > block code > END BLOCK > > > George Gallen > Senior Programmer/Analyst > Accounting/Data Division, EDI Administrator > [email protected] > ph:856.848.9005 Ext 220 > The Wyanoke Group > http://www.wyanokegroup.com > > > > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
