3 - 32 3 - 32
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.10 Displaying Characters on the Screen
The PRINT instruction is used to display text on the screen. Since this instruction is
mostly used, '?' is read as PRINT in BASIC.
Example
OK
PRINT " ABC"
ABC
OK
OK
?"ABC"
ABC
OK
Using '?' for 'PRINT'
is really convenient.
The text to be printed on the screen is specified after the PRINT instruction.
Items that can be displayed are constants, contents of variables, contents of arrays,
values of functions, and all these items combined with the operands.
Example
PRINT "ABC" The character constant "ABC" will be displayed.
PRINT A% The contents of the integer variable A% will be displayed.
PRINT A$+C$ The contents of character variable A$ plus the contents of
character variable C$ will be displayed.
Also, the texts can be displayed continuously by separating them by "," (comma) and
";" (semicolon) with the PRINT instruction.
Examples of using ";" (semicolon) are shown below.
Example
OK
A=100
OK
B=-50
OK
PRINT A;B;A+B
00 -50 50
Contents
of A
Contents of B
Contents
of A+B
OK
A$= " ABCD"
OK
B$= " EFGH"
OK
PRINT A$;B$;A$+B$
Contents
of A$
Contents of B$
Contents
of A$+B$
ABCDEFGHABCDEFGH
As shown above, when a ";" (semicolon) is used, one data is displayed, then the next
data is displayed immediately after it. The only thing to be careful is that the display
method for numeric values and characters are different.
• When numeric values are being displayed, a sign is always shown in front.
When the value is negative, "-"
When the value is positive, " " (A space is displayed.)
• When a numeric value is displayed, a space is automatically inserted after the
value. ( Example above may be easier to understand after this is said.)
Because of this, a space is inserted even if ";" is used to display data
continuously. Text display doesn't have the same characteristics, so they are
displayed continuously without spaces.