Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WHILE TRUE
- OpenAFile
- IF Failed
- BREAK
- ENDIF
- DoSomething
- IF NOT OK
- BREAK
- ENDIF
- ...etc...
- BREAK
- END WHILE
- BREAK
- BREAK
- BREAK
- BREAK
- BREAK
- #define BEGIN_AE_HANDLER while (true) {
- #define END_AE_HANDLER break; }
- #AE_CHECK_ERROR(exp) if ((exp) != noErr) { break; }
- /* code snippet */
- OSErr err = noErr;
- BEGIN_AE_HANDLER
- AE_CHECK_ERROR(err = AECreateAppleEvent( /* ... */ ));
- AE_CHECK_ERROR(err = AEPutAttributePtr( /* ... */ ));
- /* dozens of other lines, my AppleEvents are wordy */
- END_AE_HANDLER
- if (err != noErr) { /* tada */ }
- OpenAFile
- IF Failed GOTO TheEnd
- DoSomething
- IF NOT OK GOTO TheEnd
- ...etc...
- TheEnd:
- int f(int x, int y) {
- if (y < 0) { // or some other error condition
- return 0; // or throw exception
- }
- ... // perform operations
- }
- int f(int x, int y) {
- if (0 <= y) { // or some other error condition
- ... // perform operations
- } else {
- return 0;
- }
- }
- do { ... } while(false); // or whatever it's written in VB
- do { ... } while(false); // or whatever it's written in VB
- do { ... } while(false); // or whatever it's written in VB
- WHILE TRUE
- OpenAFile
- IF Failed
- BREAK
- ENDIF
- DoSomething
- IF NOT OK
- BREAK
- ENDIF
- ...etc...
- BREAK
- END WHILE
- try {
- if (!OpenAFile()) throw new StackOverflowException(); //throws an exception? otherwise the next line would be needed
- if (!DoSomething()) throw new StackOverflowException();
- etc
- } catch (StackOverflowException soex) {
- //do nothing, but it can only come from 2 places
- }
- OpenAFile
- If Failed Then Throw New IOException("Unable to open file.")
- DoSomething
- If Not OK Then Throw New ApplicationException("Couldn't DoSomething.")
- Public Function TryToDoStuff( ... ) As Boolean
- Try
- OpenAFile
- DoSomething
- Catch ioex As IOException
- Return False
- End Try
- Return True
- End Function
- do {
- doSomething();
- if (error)
- break;
- et c.
- } while (false);
- loopname:
- loop
- ...
- exit loopname when ...condition...;
- ...
- end loop loopname;
Add Comment
Please, Sign In to add comment