PRINT

The PRINT function outputs text to the screen. It accepts an unlimited number of comma-separated string or integer parameters.

When converting integer arguments, the PRINT statement will default to a decimal output. However, the user can specify a binary or hexadecimal format by using the HEX and BIN functions. All other integer conversions, including formatting of dates and times, are done using the FORMAT function.

Syntax

PRINT( [ INT expression | STRING expression ] , ... )

Parameters

expression
An expression of type INT or STRING that is to be displayed.

Example

INT state := 10;
STRING message := "hello world";
PRINT("State = ", state, ". The message is ", message, "\n");
PRINT("State = 0x", HEX(state), "\n");
PRINT("State = 0b", BIN(state), "\n");
PRINT("ASCII value of J is: ", ASC("J"), "\n");
PRINT("ASCII value 74 is '", CHAR(74), "'\n");
PRINT("State = ", FORMAT(state, "%#02x\n"));

Which will output:

State = 10. The message is hello world
State = 0xA
State = 0b1010
ASCII value of J is: 74
ASCII value 74 is 'J'
State = 0x0a

A list of special escaped characters that can be printed is listed here. The alert/bell character '\a', will sound an audible beep when printed. Note that the beep lasts 200ms and if too many are printed in quick succession then the application can become unresponsive. If your program prints multiple alert characters in a loop, then it is recommended that you insert a small sleep into the loop:

// This code prompts the user to press a key while beeping to get their attention
INT key := 0;

PRINT("Press a key to continue\n");
DO
  key := GETKEY();
WHILE (key = 0)
  PRINT("\a");
  SLEEP(500);
END;

See Also