Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

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

      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
    

    7.1.8 USING Option

    The USING option is used to format text. The print mask indicates the format for the data in the print list.

    FORMAT:


            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.

    Example 7-14 USING Option in PRINT Statement - print_mask

      let a$  = "#.## ##.##" //<---- two fields 
      print using "amount = #.##": 1.9 
      print using a$: 1.93, -1.93 
      end
     
            
    amount = 1.90 
    1.93 -1.93 
    

    The USING Print List

    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 format. However, a trailing semicolon causes Sheerpower to leave the cursor at the end of the print line.

    Example 7-15 PRINT USING

      print using "###.## ###.##": 22.88, 45;
      print " and others." 
      end
     
            
    22.88  45.00 and others. 
    

    7.1.9 Fields

    Fields are made up of format characters. The format characters tell Sheerpower how to print the expressions in the print list.

    7.1.9.1 String Format Characters

    # character

    The # is used to indicate a character position---a place in the format where a character can occur. For example:

    Example 7-16 String Format Characters in PRINT USING

      print using '#### ##': 'Test', 'Hi' 
      end
     
            
    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.

    Example 7-17 String Format Characters in PRINT USING

      print using '#### ####': 'Test', 'Hi' 
      print '123456789' 
      end
     
            
    Test  Hi 
    123456789 
    

    If the string expression is longer than the field, Sheerpower generates an exception.

    7.1.9.2 Numeric Format Characters

    # character

    The # can also be used to specify digits. Each # represents one numeric digit position.

    Example 7-18 Numeric Format Characters in PRINT USING

       print using "##": 19 
       end
     
            
    19 
    

    If more positions than the numeric expression contains are indicated, the expression will be right-justified and padded with spaces.

    Example 7-19 Numeric Format Characters in PRINT USING

      print '1st 2nd 3rd' 
      print using "### ### ###": 193, 19, 1 
      end
     
            
    1st 2nd 3rd 
    193  19   1 
    

    Sheerpower prints a minus sign in front of negative numbers. Sheerpower does not print a sign in front of positive numbers.

    Example 7-20 Numeric Format Characters in PRINT USING - Negative and Positive Numbers

      print '1st 2nd 3rd' 
      print using "### ### ###": 193, 19, -1
      end
     
            
    1st 2nd 3rd 
    193  19  -1 
    

    If more positions to the left of the decimal point than the expression contains are indicated, the expression will be printed with leading spaces.

    Example 7-21 Numeric Format Characters in PRINT USING

      print using "###.##": 1.9 
      end
     
            
    1.90 
    

    If more positions to the right of the decimal point than the expression contains are indicated, the expression will be printed with trailing zeros.

    Example 7-22 Numeric Format Characters in PRINT USING

      print '--1-- --2--' 
      print using "##.## ##.##": 1.3, 1.25 
      end
     
            
    --1-- --2-- 
     1.30  1.25 
    


    Previous Next Contents Index