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.
enviar mensaje [message]
Parameters |
Description |
---|---|
message |
The string to send to the other linked robot. |
Example
cuando la pantalla [presionado v] :: hat events
[Press the screen to send a message to the other robot.]
enviar mensaje [message]
cuando empezó :: hat events
[Display when a message is received.]
esperar hasta <¿Está disponible el mensaje?>
imprimir [Received!] en la pantalla ▶
send message with data#
The send message with data block sends a string and a number to the other linked robot.
enviar mensaje [message] con datos [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
cuando la pantalla [presionado v] :: hat events
[Send the current heading to the other robot.]
enviar mensaje [message] con datos (rumbo en grados)
cuando empezó :: hat events
[Turn to match the other robot's heading.]
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
get latest message#
The get latest message block stores the most recent string received from the other linked robot.
recibir el último mensaje
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Display the received message.]
esperar hasta <¿Está disponible el mensaje?>
recibir el último mensaje
imprimir (último mensaje) en la pantalla ▶
cuando la pantalla [presionado v] :: hat events
[Send "VEXcode!" to the other robot.]
enviar mensaje [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.
Obtenga el último mensaje con datos
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Turn to match the other robot's heading.]
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
cuando la pantalla [presionado v] :: hat events
[Send the current heading to the other robot.]
enviar mensaje [message] con datos (rumbo en grados)
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.
(último mensaje)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Display the received message.]
esperar hasta <¿Está disponible el mensaje?>
recibir el último mensaje
imprimir (último mensaje) en la pantalla ▶
cuando la pantalla [presionado v] :: hat events
[Send "VEXcode!" to the other robot.]
enviar mensaje [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.
(últimos datos)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Turn to match the other robot's heading.]
para siempre
si <¿Está disponible el mensaje?> entonces
Obtenga el último mensaje con datos
girar hacia el rumbo (últimos datos) grados ▶
cuando la pantalla [presionado v] :: hat events
[Send the current heading to the other robot.]
enviar mensaje [message] con datos (rumbo en grados)
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.
<¿Está disponible el mensaje?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Display when a message is received.]
esperar hasta <¿Está disponible el mensaje?>
imprimir [Message received!] en la pantalla ▶
cuando la pantalla [presionado v] :: hat events
[Press the screen to send a message to the other robot.]
enviar mensaje [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.
<¿está conectado?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Turn off one of the linked robots to see the message change.]
para siempre
pantalla clara
imprimir <¿está conectado?> en la pantalla ▶