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#

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.

<有消息吗?>

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.]
永久循环
清屏
在屏幕上打印 <已连接?>▶