qb45advr.hlp (Topic list)
PRINT Statement Programming Examples
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
PRINT Statement Programming Examples
 
These examples show the use of commas and semicolons with PRINT.
 
Example 1
 
Here is an example of using commas in a PRINT statement to print each
value at the beginning of the next print zone:
 
CLS                ' Clear screen
X = 5
PRINT X + 5, X - 5, X * (-5), X ^ 5
END
 
Sample Output
 
 10            0            -25            3125
 
Example 2
 
In this example, the semicolon at the end of the first PRINT
statement makes the first two PRINT statements print on the
same line. The last PRINT statement prints a blank line before
the next prompt
 
CLS                ' Clear screen
DO
   INPUT "Input X (type 0 to quit): ", X
   IF X = 0 THEN
      EXIT DO
   ELSE
      PRINT X; "squared is"; X ^ 2; "and";
      PRINT X; "cubed is"; X^3
      PRINT
   END IF
LOOP
 
Sample Output
 
Input X (type 0 to quit): 9
 9 squared is 81 and 9 cubed is 729
 
Input X (type 0 to quit): 21
 21 squared is 441 and 21 cubed is 9261
 
Input X (type 0 to quit): 0
 
Example 3
 
In this example, the semicolons in the PRINT statement print each
value immediately after the preceding value. Note that a space
always follows a number and precedes a positive number:
 
CLS                ' Clear screen
FOR X = 1 TO 5
  J = J + 5
  K = K + 10
  PRINT J; K;
NEXT X
 
Sample Output
 
 5  10  10  20  15  30  20  40  25  50