FANDOM


Syntax

THROW word

Explanation

THROW returns control to the CATCH statement with a matching first input, or to the CATCH TRUE statement if no matching CATCH statement is found.

Examples:

The following example asks you to type a name. If you type a number instead, the program prints a message and continues.

TO NAMIT

CATCH "NOTNAME [NAMIT1 STOP]
NAMIT

END

TO NAMIT1

PRINT [PLEASE TYPE A NAME]
MAKE "NAME READ
IF NUMBER? :NAME [PRINT [THAT'S A NUMBER, NOT A NAME] THROW "NOTNAME]
PRINT (SE :NAME [IS A GOOD NAME])

END

? NAMIT

PLEASE TYPE A NAME

? KURT

KURT IS A GOOD NAME

PLEASE TYPE A NAME

? 5

THAT'S A NUMBER NOT A NAME

?

Type Control-G to return to toplevel.

In the following example, AVOID.INTERRUPTIONS runs the commands you type. If an error occurs, Logo prints

THAT'S NOT A LOGO COMMAND

and continues executing the procedure instead of printing the usual Logo message and terminating the procedure by returning to toplevel.

TO AVOID.INTERRUPTIONS

CATCH "ERROR [AVOID.INTERRUPTIONS1]
PRINT [THAT'S NOT A LOGO COMMAND]
AVOID.INTERRUPTIONS

END

TO AVOID.INTERRUPTIONS1

RUN READLIST
AVOID.INTERRUPTIONS1

END

? AVOID.INTERRUPTIONS

? PRINT [THIS IS RIGHT]

THIS IS RIGHT

? PRINT THIS IS RIGHT

THAT'S NOT A LOGO COMMAND

? Type TOPLEVEL or Control-G to return to toplevel.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.