FANDOM


Syntax

DEFEVENT eventname eventprocedure

Explanation

The DEFEVENT command attaches a Logo procedure to a specific event. Whenever this event occurs, the attached Logo procedure will be called. Its first input is a name which is the name of the event, while the second input is the name of the procedure which is to be attached to that event.

Currently, there are two events defined which you can overload. The BREAK event occurs every time the Control-G key is being pressed. Normally, a built-in event procedure will turn off the timer ticks (if a timer has been activated with the TIMER command) and return you to toplevel. You can modify this behaviour by defining an event procedure for the BREAK event. This procedure should, however, provide the option of returning to toplevel. If you omit this option, pressing Control-G will not return you to toplevel or even break any existing procedures. Also, you might want to turn off the timer during the event processing. The TIMER event is activated with the TIMER command. This command starts a timer which, when elapsed, generates a TIMER event which can be used to activate a Logo procedure. Both the BREAK and the TIMER events do not generate any inputs for the event handling procedures.

See also EVENT and TIMER.

Example

The following procedure is a replacement for the built-in BREAK handler. It will ask for confirmation of the break request before returning to toplevel.

TO MY.OWN.BREAK

LOCAL "ANSWER
PR "BREAK!
TYPE [RETURN TO TOPLEVEL? |(Y/N)|]
MAKE "ANSWER RC
(PR)
IF :ANSWER = "Y THEN \
IGNORE TIMER "FALSE \
(HALT) \
TOPLEVEL

END

? DEFEVENT "BREAK "MY.OWN.BREAK

?

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.