Message#
Introduction#
Two VEX AIM Coding Robots can be linked so they communicate during a project. Using Message blocks, the robots can send and receive information to coordinate their actions.
Note: For messages to be sent and received, both robots must be running projects that handle messaging at the same time.
Below is a list of all available blocks:
send message – Sends a string to the other linked robot.
send message with data – Sends a string and a number to the other linked robot.
get latest message – Stores the most recent string received.
get latest message with data – Stores the most recent string and number received.
latest message – Returns the most recent stored string.
latest data – Returns the most recent stored number.
is message available? – Returns a Boolean indicating whether the other linked robot has ever sent a message.
is connected? – Returns a Boolean indicating whether the robot is linked with another robot.
send message#
The send message block sends a string to the other linked robot.
发送消息 [message]
Parameters |
Description |
---|---|
message |
The string to send to the other linked robot. |
Example
当屏幕 [pressed v] :: hat events
[Press the screen to send a message to the other robot.]
发送消息 [message]
当开始 :: hat events
[Display when a message is received.]
等到 <有消息吗?>
在屏幕上打印 [Received!]▶
send message with data#
The send message with data block sends a string and a number to the other linked robot.
发送带有数据 [message]消息 [0]
Parameters |
Description |
---|---|
message |
The value to send to the other linked robot. This must be a string. |
data |
A number to send to the other robot. |
Example
当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)
当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶
get latest message#
The get latest message block stores the most recent string received from the other linked robot.
获取最新消息
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Display the received message.]
等到 <有消息吗?>
获取最新消息
在屏幕上打印 (最新消息)▶
当屏幕 [pressed v] :: hat events
[Send "VEXcode!" to the other robot.]
发送消息 [VEXcode!]
get latest message with data#
The get latest message with data block stores the most recent string and number received from the other linked robot.
获取带有数据的最新消息
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶
当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)
latest message#
The latest message block returns the most recent stored string from the last use of the get latest message or get latest message with data block.
(最新消息)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Display the received message.]
等到 <有消息吗?>
获取最新消息
在屏幕上打印 (最新消息)▶
当屏幕 [pressed v] :: hat events
[Send "VEXcode!" to the other robot.]
发送消息 [VEXcode!]
latest data#
The latest data block returns the most recent stored number from the last use of the get latest message with data block.
(最新数据)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶
当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)
is message available?#
The is message available? block returns a Boolean indicating whether the other linked robot has ever used the send message or send message with data block yet in the current project.
True - The send message or send message with data block has been used by the other linked robot in the current project.
False - The send message or send message with data block has never been used by the other linked robot in the current project.
<有消息吗?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Display when a message is received.]
等到 <有消息吗?>
在屏幕上打印 [Message received!]▶
当屏幕 [pressed v] :: hat events
[Press the screen to send a message to the other robot.]
发送消息 [message]
is connected?#
The is connected? block returns a Boolean indicating whether the robot is currently linked with another robot.
True - The robot is linked with another robot.
False - The robot is not linked with another robot.
<已连接?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
当开始 :: hat events
[Turn off one of the linked robots to see the message change.]
永久循环
清屏
在屏幕上打印 <已连接?>▶