PRINT
This page was last modified 07:56, 29 January 2018 by NYYRIKKI. Based on work by Mars2000you.

Contents

Effect

Used to display and format text and numbers to user as well as to send data to different devices through file handling.

It can be replaced by the "?" character. This will be expanded to "PRINT" when listing a MSX-BASIC program.

Syntax

PRINT [#<file number>,] [USING <format string>;] [<print list>]

Parameters

<print list> is a list of variables, constants or expressions to print. Different types can be mixed freely. Print list can contain 0 or more items separated by ";" or ",". If the print list does not end to ";" or "," CR+LF combination is printed after the list. When the list is separated with ";" the items are printed right after each other. In case of "," they are separated by tabulator. These list separators can be mixed with each other.

<file number> is a number between 0 and 15 that points to opened file name. Please see OPEN instruction.

<format string> is a string that defines how the print list is formatted. The format sting can contain following definitions:

Editor's note: Following table and comments are inaccurate and need revisiting. Please help.

Format definition Data type Description
 ! String Prints only first character of current item.
\ String Swap 1st and last character???
& String Represents any number of spaces. All data after it are moved to right in order to make the string fit???
# Number Reserves a space (up to 24) for number. Desimal point can be defined or not.
+ Number Positive numbers will be written with "+"-sign
- Number Can be used to mark "-" to end of number when the number is negative
** Number Will represent two numbers and change heading spaces to "*"
££ Number Will cause floating pound sign to be printed on front of number.
**£ Number Will cause floating pound sign to be printed on front of number and change heading spaces to "*"
, Number Numbers will be printed in groups of 3 separated by ","
^^^^ Number This in the end of definition will cause number to be printed in exponential format.


Please note:" Format string should be used with caution. Pound signs should be avoided since this causes compatibility problem. On some machines this is "$" depending on local currency. "&" has been replaced with "\" on european and Brazilian machines causing easily "Type missmatch" error in localized machines. In Japanese machines "\" is printed as "¥"

Examples

10 FM$="The print documentation on & & has ##.#% relative accuracy"
20 PRINT USING FM$;"MRC",5
 
RUN
The print documentation on MRC has  5.0% relative accuracy
Ok
PRINT USING "!!!";"Alpha";"Beta";"Charlie"
ABC
Ok

Related to

CSRLIN, LOCATE, LPRINT, MAXFILES, OPEN, POS(), SCREEN, WIDTH

Compatibility

MSX-BASIC 1.0 or higher