Send: Difference between revisions
mNo edit summary |
(→Quirks: #send command length limit) |
||
(One intermediate revision by one other user not shown) | |||
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>. | ||
* Following the <code>#send</code> (excluding the space after it) or <code>#</code> in the <code>#label</code> shortcut, a message cannot exceed 20 characters in length. If it does, the engine will truncate the message to 20 characters and attempt to execute the resulting command. An error message will be thrown only if the <code>#label</code> shortcut is used and the truncated version of the label does not exist. The engine will also truncate any <code>name:label</code>, <code>all:label</code>, <code>others:label</code>, or even <code>self:label</code> command that exceeds 20 characters; it will then either execute the truncated label in the target object, or attempt to jump to a label with the truncated target name, depending on where the command is cut off, without throwing an error message if neither such label can be found. | |||
{{ZZT-OOP navbox}} | {{ZZT-OOP navbox}} |
Latest revision as of 06:40, 22 September 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
. - Following the
#send
(excluding the space after it) or#
in the#label
shortcut, a message cannot exceed 20 characters in length. If it does, the engine will truncate the message to 20 characters and attempt to execute the resulting command. An error message will be thrown only if the#label
shortcut is used and the truncated version of the label does not exist. The engine will also truncate anyname:label
,all:label
,others:label
, or evenself:label
command that exceeds 20 characters; it will then either execute the truncated label in the target object, or attempt to jump to a label with the truncated target name, depending on where the command is cut off, without throwing an error message if neither such label can be found.
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |