Skip to content

sendTEXT

Jason Watkins edited this page May 8, 2015 · 6 revisions

Sets a message that X-Plane will display on the screen.

Syntax

Language Signature
C int sendTEXT(XPCSocket sock, char* msg, int x, int y)
MATLAB sendTEXT( msg, x, y, socket )
Java void sendTEXT(String msg, int x, int y)
Python sendTEXT(self, msg, x = -1, y = -1)
Parameters

sock (C): The socket used to send the command.

msg: The string to display on the screen

x: The distance in pixels from the left edge of the screen to display the message. A value of -1 indicates that the default horizontal position should be used.

y: The distance in pixels from the bottom edge of the screen to display the message. A value of -1 indicates that the default vertical position should be used.

socket (MATLAB): An optional reference to a socket opened with openUDP that should be used to send the command.

Return value

C: A negative value if an error occurs, otherwise 0.

Remarks

The sendTEXT command supports a single message at any given time. Setting a new message will overwrite any previously set message. Multiple lines are supported, however only a single line break should be used. Windows style line breaks (i.e. CRLF/\r\n) will be rendered as two line breaks.

Exceptions

C Error Code Java Exception Python Error Description
-1 - - The specified y coordinate is off the screen
-2 IllegalArgumentException ValueError The message is too long
-3 IOException OSError The client is unable to send the command

Examples

C
#include "xplaneConnect.h"
XPCSocket sock = openUDP(49077, IP, PORT);

// Display 'Hello from C' at the default location
sendTEXT(sock, "Hello from C", -1, -1);

closeUDP(sock);
MATLAB
import XPlaneConnect.*;

% Display 'Hello from MATLAB' 100 pixels from the
% left and bottom edges of the screen
sendTEXT('Hello from MATLAB', 100, 100);
Java
import gov.nasa.xpc.XPlaneConnect;

try(XPlaneConnect xpc = new XPlaneConnect())
{
    // Display 'Hello from Java' 100 pixels from the left
    // edge of the screen and at the default height
    xpc.sendTEXT("Hello from Java", 100, -1);
}

Python

import xpc

with xpc.XPlaneConnect() as client:
    # Display 'Hello from Java' 100 pixels from the left
    # edge of the screen and at the default height
    client.sendTEXT("Hello from Python", 100, -1)