Previous | Contents | Index |
6.1 PRINT
The PRINT statement prints or displays text on the
screen. The printed text can be formatted using a mask or directive
and/or highlighted using video options. This section describes the
various ways that text can be displayed on the screen.
PRINT [[AT row, col] [,ERASE] [,WIDE] [,BLINK] [,UNDERLINE] [,REVERSE] [,BOLD] [,USING "print_mask"]:] expr [{, | ;} expr...] [, | ;] |
10 INPUT name$ PRINT 'Hello, '; name$ PRINT BOLD, UNDERLINE: 'Here is a number: 1.93' 20 END RNH ? Rick Hello, Rick Here is a number: 1.93 |
The simplest version of the PRINT statement is:
PRINT expr |
expr is an expression to print. expr can be any INTOUCH expression. INTOUCH prints the value of the expression at the current cursor position and then generates a new line. A PRINT statement without an expression simply generates a new line.
The ? can be used as a synonym for PRINT at the command prompt.
10 PRINT 'Line 1' PRINT PRINT 'Line 3' 20 END RNH Line 1 Line 3 |
One PRINT statement can print several items. Multiple items must be separated with a comma or a semicolon. The separator determines where the next expression will be printed.
You can use two additional features to position the cursor:
Separating print items with a semicolon causes the items to immediately follow one another. When the items are printed, no spaces appear between the expressions.
10 alpha$ = 'ABCDEFGHIJKLM' bet$ = 'NOPQRSTUVWXYZ' PRINT alpha$; bet$ 20 END RNH ABCDEFGHIJKLMNOPQRSTUVWXYZ |
You can print in columns by using print zones. Each print zone has a default width of twenty characters. To change the width, see Section 9.17.2, SET ZONEWIDTH.
|-------------------|-------------------|-------------------| 1 20 40 60 |
Separating items with a comma causes the item following the comma to be printed in a new print zone. The terminal width determines the number of zones in each line. (See Section 9.8.1, ASK MARGIN statement to determine the terminal width.)
10 INPUT name_1$, name_2$ 20 PRINT name_1$, 'MARY', name_2$ 30 END RNH ? FRED, JOHN FRED MARY JOHN |
If an item is longer than the zone width, INTOUCH continues it into the next print zone. INTOUCH uses as many print zones as necessary to print an item.
RNH ? FRED, DILLENSCHNEIDER & SONS FRED MARY DILLENSCHNEIDER & SONS |
INTOUCH writes data sequentially. If an item is too long (over 132 characters) to write in one record, INTOUCH continues it in the next record.
10 OPEN #1: NAME 'test.tmp', ACCESS OUTPUT PRINT #1: REPEAT$('+-', 100) CLOSE #1 20 OPEN #1: NAME 'test.tmp', ACCESS INPUT LINE INPUT #1: record_1$, record_2$ PRINT 'Record 1: '; record_1$ PRINT 'Record 2: '; record_2$ CLOSE #1 30 END RNH Record 1: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Record 2: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
The TAB function moves the print position to a specified column.
TAB(column) |
column is the column position to print. TAB positions the cursor at the column specified. TAB always moves forward (to the right). If the cursor is at or past the column specified, INTOUCH jumps to the next line. The TAB function is a print item. Therefore, it must be separated from other print items with a comma or a semicolon.
10 INPUT name_1$, name_2$ 20 PRINT TAB(5); name_1$; TAB(20); 'MARY'; TAB(35); name_2$ 30 END RNH ? FRED, JOHN FRED MARY JOHN |
The AT option moves the cursor to a specificed row and column on the screen.
AT row, column |
row is the row to print at. column is the column to print at. Row and column can be any integer numeric constants.
10 INPUT name_1$, name_2$ 20 CLEAR 30 PRINT AT 3,10: name_1$; TAB(20); 'Mary'; TAB(35); name_2$ 40 END RNH ? Fred, John FRED MARY JOHN |
The ERASE option erases from the end of the printed text to the end of the line.
10 CLEAR 20 PRINT AT 10, 1: 'Mary had a little lamb' DELAY 2 30 PRINT AT 10, 1: 'Jeff' DELAY 2 40 PRINT ERASE, AT 10, 1: 'Caroline' DELAY 2 50 END RNH Mary had a little lamb . . . Jeff had a little lamb . . . Caroline |
This option prints double-width characters on the terminal screen.
10 PRINT WIDE: 'INTOUCH' 20 END |
The following rules govern the printing of numbers:
10 LET x = 7 LET y = 10 PRINT x; y 20 END RNH 7 10 |
10 LET x = -7 LET y = -10 PRINT x; y 20 END RNH -7 -10 |
10 LET x = 700000000001 PRINT x 20 END RNH 700000000001 |
10 LET x = 700000000001.89 PRINT x 20 END RNH 700000000002 |
10 LET X = 70000000000001.89 PRINT X 20 END RNH .7E+14 |
INTOUCH prints:
6.1.7 Positioning the Cursor for the Next Print Statement
If a separator (comma, semicolon, TAB function or AT option) is the
last item in the PRINT statement, INTOUCH advances the cursor to the
position specified and does not generate a new line.
10 PRINT TAB(5); 7, PRINT 10; PRINT 20 20 END RNH 7 10 20 |
The video attribute options highlight text on the screen. Separate the options from the print list with a colon. The options are:
BLINK | causes the expressions in the print list to blink in low and high intensity | |
UNDERLINE | causes the print list to be underlined | |
BOLD | causes the expressions in the print list to appear in bold (high intensity) | |
REVERSE | causes the print list to appear in reverse video |
The video options can be combined. For example, the following program will print "Hello" boldfaced and in reverse video. It will then blink and underline the word "Goodbye".
10 PRINT BOLD, REVERSE: 'Hello' 20 PRINT UNDERLINE, BLINK: 'Goodbye' 30 END |
The USING option is used to format text. The print mask indicates the format for the data in the print list.
USING print_mask |
The print_mask consists of fields or directives and text. The text can precede or follow a field or directive. The print mask tells how to print the expressions in the print list.
fields / \ 10 LET a$ = "#.## ##.##" 20 PRINT USING "amount = #.##": 1.9 30 PRINT USING a$: 1.93, -1.93 40 END RNH amount = 1.90 1.93 -1.93 |
Expressions in the print list with the USING option are separated by commas. A trailing semicolon is allowed. The expressions are printed according to the the format. However, a trailing semicolon causes INTOUCH to leave the cursor at the end of the print line.
10 PRINT USING "###.## ###.##": 22.88, 45; 20 PRINT " and others." 30 END RNH 22.88 45.00 and others. |
Fields are made up of format characters. The format characters tell INTOUCH how to print the expressions in the print list.
6.1.10.1 String Format Characters
The # is used to indicate a character position---a place in the format where a character can occur. For example:
10 PRINT USING '#### ##': 'Test', 'Hi' 20 END RNH Test Hi |
In the above example, there are two fields. When the first string is printed, the word "Test" occupies all four character positions. When the second expression is printed (Hi), only two character positions are used.
If the string expression being printed is smaller than the field, the expression will be printed centered within the field.
10 PRINT USING '#### ####': 'Test', 'Hi' 15 PRINT '123456789' 20 END RNH Test Hi 123456789 |
If the string expression is longer than the field, INTOUCH generates an exception.
6.1.10.2 Numeric Format Characters
The # can also be used to specify digits. Each # represents one numeric digit position.
10 PRINT USING "##": 19 20 END RNH 19 |
If you indicate more positions than the numeric expression contains, the expression will be right-justified and padded with spaces.
10 PRINT '1st 2nd 3rd' 20 PRINT USING "### ### ###": 193, 19, 1 30 END RNH 1st 2nd 3rd 193 19 1 |
INTOUCH prints a minus sign in front of negative numbers. INTOUCH does not print a sign in front of positive numbers.
10 PRINT '1st 2nd 3rd' 20 PRINT USING "### ### ###": 193, 19, -1 30 END RNH 1st 2nd 3rd 193 19 -1 |
If you indicate more positions to the left of the decimal point than the expression contains, the expression will be printed with leading spaces.
10 PRINT USING "###.##": 1.9 20 END RNH 1.90 |
If you indicate more positions to the right of the decimal point than the expression contains, the expression will be printed with trailing zeros.
10 PRINT '--1-- --2--' 20 PRINT USING "##.## ##.##": 1.3, 1.25 30 END RNH --1-- --2-- 1.30 1.25 |
The less than sign left-justifies text within a field. The less than sign must appear at the beginning of a field. The less than sign counts as a character position. In this example, justification occurs only in the second field.
10 PRINT USING "#### <###": 'Test', 'Hi' 20 PRINT '123456789' 30 END RNH Test Hi 123456789 |
In the above example, there are two fields. When the first string is printed, the word "Test" occupies all four character positions. The less than sign (<) causes INTOUCH to left-justify the second expression.
The greater than sign is used to right-justify text within a field. The greater than sign must appear at the beginning of a field. The greater than sign counts as a character position.
10 PRINT USING "#### >###": 'Test', 'Hi' 20 PRINT '123456789' 30 END RNH Test Hi 123456789 |
In the above example, there are two fields. The greater than sign (>) causes INTOUCH to right-justify the second expression.
The @ indicates one character position with no translation.
10 PRINT USING '####': 0001 20 PRINT USING '@@@@': 0001 30 END RNH 1 0001 |
You can include a decimal point in a number by putting a period or decimal point in the format.
10 PRINT USING "###.##": 19.3 20 END RNH 19.30 |
You can include commas in your numbers by putting commas in the format.
10 a$ = "##,###.##" 20 PRINT USING a$: 28290.06 PRINT USING A$: 8290.06 PRINT USING A$: 290.06 30 END RNH 28,290.06 8,290.06 290.06 |
Commas cannot be used in exponential format.
The % character pads on the left with zeros.
10 PRINT '-1- -2- -3-' PRINT USING "%%% %%% %%%": 193, 19, 1 20 END RNH -1- -2- -3- 193 019 001 |
The * character pads on the left with asterisks. You can use this symbol for setting up check amounts.
10 PRINT USING '***,***.**': 19.42 20 END RNH *****19.42 |
If the expression is smaller than the format, INTOUCH will right justify the expression and pad it with asterisks.
10 PRINT '-1- -2- -3-' PRINT USING "*** *** ***": 193, 19, 1 20 END RNH -1- -2- -3- 193 *19 **1 |
A plus sign causes INTOUCH to print a leading plus or minus sign. INTOUCH will print a plus sign in front of positive numbers and a minus sign in front of negative numbers.
The "+" sign adds a character position to the format. The character position is used for the sign of the number.
10 PRINT ' -1- -2- -3-' PRINT USING "+### +### +###": 193, 19, -1 20 END RNH -1- -2- -3- +193 +19 -1 |
Prints a leading or trailing minus sign for negative numbers, and a leading space for positive numbers. The "-" adds a character position to the format. The character position is used to print the minus sign or space.
10 PRINT ' -1- -2- -3-' PRINT USING "-### -### -###": 193, 19, -1 20 END RNH -1- -2- -3- 193 19 -1 |
Prints a floating dollar sign. The dollar sign appears before the number. $ causes INTOUCH to print '$-' for negative numbers and '$' for positive numbers. The minus sign appears immediately after the dollar sign and before the number.
10 PRINT "1st col 2nd col" PRINT USING "$###.## $###.##": 11.93, -1.93 20 END RNH 1st col 2nd col $11.93 $-1.93 |
Prints a floating dollar sign. The dollar sign appears before the numeric expression. $+ causes INTOUCH to print a minus sign before negative numbers, and a plus sign before positive numbers.
The sign appears after the dollar sign and before the number.
10 PRINT "1st col 2nd col" PRINT USING "$+###.## $+###.##": 11.93, -1.93 20 END RNH 1st col 2nd col $+11.93 $-1.93 |
Prints a floating dollar sign. The dollar sign appears immediately before the numeric expression. -$ causes INTOUCH to print a minus sign before negative numbers and a space before positive numbers. The minus sign or space appears immediately before the dollar sign.
10 PRINT "1st col 2nd col" PRINT USING "-$###.## -$###.##": 11.93, -1.93 20 END RNH 1st col 2nd col $11.93 -$1.93 |
+$ causes INTOUCH to print a floating dollar sign. The dollar sign appears immediately before the number. +$ causes INTOUCH to print a plus sign before positive numbers and a minus sign before negative numbers. The plus or minus sign appears immediately before the dollar sign.
10 PRINT "1st col 2nd col" PRINT USING "+$###.## +$###.##": 11.93, -1.93 20 END RNH 1st col 2nd col +$11.93 -$1.93 |
Notice that +$ adds two character positions to the format. One position contains the dollar sign, the other contains the plus or minus sign.
Previous | Next | Contents | Index |