| Previous | Contents | Index |
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] [,REVERSE]
[,BOLD] [,USING "print_mask"]:] expr [{, | ;} expr...] [, | ;]
|
| Example 7-1 PRINT statement |
|---|
input name$
print 'Hello, '; name$
print bold: 'Here is a number: 1.93'
end
? 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 SheerPower expression. SheerPower 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.
| Example 7-2 Print expression |
|---|
print 'Line 1'
print
print 'Line 3'
end
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.
Two additional features can be used 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.
| Example 7-3 Semicolon in PRINT statement |
|---|
alpha$ = 'ABCDEFGHIJKLM'
bet$ = 'NOPQRSTUVWXYZ'
print alpha$; bet$
end
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
Print in columns by using print zones. Each print zone has a default width of twenty characters. To change the width, see Section 11.16.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 11.9.1, ASK MARGIN statement to determine the terminal width.)
| Example 7-4 Commas and Print Zones |
|---|
input name_1$, name_2$
print name_1$, 'MARY', name_2$
end
? FRED, JOHN <------ type in FRED, JOHN
FRED MARY JOHN
|
If an item is longer than the zone width, SheerPower continues it into the next print zone. SheerPower uses as many print zones as necessary to print an item.
? FRED, DILLENSCHNEIDER & SONS
FRED MARY DILLENSCHNEIDER & SONS
|
SheerPower writes data sequentially. If an item is too long (over 132 characters) to write in one record, SheerPower continues it in the next record.
| Example 7-5 Printing long data in records |
|---|
open #1: name 'test.txt', access output
set #1: margin 80
print #1: repeat$('+-', 70)
close #1
open #1: name 'test.txt', access input
line input #1: record_1$, record_2$
print 'Record 1: '; record_1$
print 'Record 2: '; record_2$
close #1
end
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, SheerPower 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.
| Example 7-6 TAB in PRINT statement |
|---|
input name_1$, name_2$
print tab(5); name_1$; tab(20); 'MARY'; tab(35); name_2$
end
? FRED, JOHN
FRED MARY JOHN
|
The AT option moves the cursor to a specified 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.
| Example 7-7 AT row, column in PRINT statement |
|---|
input name_1$, name_2$
clear
print at 3,10: name_1$; tab(20); 'Mary'; tab(35); name_2$
end
? Fred, John <------- type in 'Fred, John'
FRED MARY JOHN
|
The ERASE option erases from the end of the printed text to the end of the line.
| Example 7-8 ERASE in PRINT statement |
|---|
print at 10, 1: 'Mary had a little lamb'
delay 2
print at 10, 1: 'Jeff'
delay 2
print erase, at 10, 1: 'Caroline'
delay 2
end
Mary had a little lamb
.
.
.
Jeff had a little lamb
.
.
.
Caroline
|
The following rules govern the printing of numbers:
| Example 7-9 Printing numbers with PRINT statement |
|---|
let x = 7
let y = 10
print x; y
end
7 10
|
| Example 7-10 Printing negative numbers with PRINT statement |
|---|
let x = -7
let y = -10
print x; y
end
-7 -10
|
| Example 7-11 Printing integers of 12 or fewer digits |
|---|
let x = 700000000001
print x
end
700000000001
|
SheerPower prints:
If a separator (comma, semicolon, TAB function or AT option) is the last item in the PRINT statement, SheerPower advances the cursor to the position specified and does not generate a new line.
| Example 7-12 Cursor positioning in PRINT statement |
|---|
print tab(5); 7,
print 10;
print 20
end
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 |
| 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 the word "Goodbye".
| Example 7-13 Printing Attributes--Highlighting Options |
|---|
print bold, reverse: 'Hello' print blink: 'Goodbye' end |
| Previous | Next | Contents | Index |