SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index


Chapter 7
Printing and Displaying Data

7.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.

FORMAT:


        PRINT [[AT row, col] [,ERASE] [,WIDE] [,BLINK] [,REVERSE] 
        [,BOLD] [,USING "print_mask"]:] expr [{, | ;} expr...] [, | ;] 

EXAMPLE:

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

DESCRIPTION:

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 

7.1.1 Printing Multiple Expressions

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:

Semicolons

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 

Commas and Print Zones

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: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 

7.1.2 TAB Function

The TAB function moves the print position to a specified column.

FORMAT:


        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 

7.1.3 AT Option

The AT option moves the cursor to a specified row and column on the screen.

FORMAT:


        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 

7.1.4 ERASE Option

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 

7.1.5 Printing Numbers

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 


  • Negative numbers are preceded by a minus sign.
  • Example 7-10 Printing negative numbers with PRINT statement

      let x = -7 
      let y = -10 
      print x; y 
      end
     
            
    -7 -10 
    

  • If a number can be represented as an integer of 12 or fewer digits, it is printed as such.
  • Example 7-11 Printing integers of 12 or fewer digits

      let x = 700000000001 
      print x 
      end
     
            
    700000000001 
    

    SheerPower prints:

    7.1.6 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, 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 
    

    7.1.7 Printing Attributes - Highlighting Options

    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