Send: Difference between revisions
mNo edit summary |
m (whitespace) |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:send}} | {{DISPLAYTITLE:send}} | ||
'''#send''' is a [[ZZT-OOP]] command that provides a means of directing one or multiple [[object|objects.]] When an object receives a message from '''#send''', it checks its program for a matching [[label]], and if found, continues program execution from that point. ZZT's manual compares it to the GOTO statement in BASIC. | '''#send''' is a [[ZZT-OOP]] command that provides a means of directing one or multiple [[object|objects.]] When an object receives a message from '''#send''', it checks its program for a matching [[label]], and if found, continues program execution from that point. ZZT's manual compares it to the GOTO statement in BASIC. | ||
Objects can send messages to themselves to control their own program flow, as well as send to other objects. An object can manage multiple instances of a label with [[zap|#zap and #restore]], allowing different reactions to the same received message string. If an object needs to perform a task without interruption, it can turn off all incoming messages with the [[lock|#lock]] command. | Objects can send messages to themselves to control their own program flow, as well as send to other objects. An object can manage multiple instances of a label with [[zap|#zap and #restore]], allowing different reactions to the same received message string. If an object needs to perform a task without interruption, it can turn off all incoming messages with the [[lock|#lock]] command. | ||
== Syntax == | == Syntax == | ||
Line 11: | Line 9: | ||
'''#send''' is unique among ZZT-OOP commands in that the command part can be omitted as a shortcut: <code>#label</code> is functionally identical to <code>#send self:label</code>, so long as <code>:label</code> exists somewhere in the code and ''label'' isn't the name of a command like <code>[[die|#die]]</code>. | '''#send''' is unique among ZZT-OOP commands in that the command part can be omitted as a shortcut: <code>#label</code> is functionally identical to <code>#send self:label</code>, so long as <code>:label</code> exists somewhere in the code and ''label'' isn't the name of a command like <code>[[die|#die]]</code>. | ||
== Quirks == | == Quirks == | ||
* A locked object will not receive external messages, but it can still '''#send''' messages to itself. This includes when sending to all objects with <code>#send all:label</code>. | * A locked object will not receive external messages, but it can still '''#send''' messages to itself. This includes when sending to all objects with <code>#send all:label</code>. | ||
{{ZZT-OOP navbox}} | {{ZZT-OOP navbox}} |
Revision as of 03:18, 13 February 2021
#send is a ZZT-OOP command that provides a means of directing one or multiple objects. When an object receives a message from #send, it checks its program for a matching label, and if found, continues program execution from that point. ZZT's manual compares it to the GOTO statement in BASIC.
Objects can send messages to themselves to control their own program flow, as well as send to other objects. An object can manage multiple instances of a label with #zap and #restore, allowing different reactions to the same received message string. If an object needs to perform a task without interruption, it can turn off all incoming messages with the #lock command.
Syntax
- Object sending a label to itself:
#send self:<label>
- Object sending a label to multiple objects (and possibly itself as well):
#send <all|others|name>:<label>
#send is unique among ZZT-OOP commands in that the command part can be omitted as a shortcut: #label
is functionally identical to #send self:label
, so long as :label
exists somewhere in the code and label isn't the name of a command like #die
.
Quirks
- A locked object will not receive external messages, but it can still #send messages to itself. This includes when sending to all objects with
#send all:label
.
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |