The PRINT statement transfers program data to a terminal or a terminal-format file. Examples PRINT "THE ANSWER IS ";C% PRINT #2%, Emp_num, Emp_name$; Emp_age%
1 – Syntax
PRINT [chnl-exp,][ output-list ] output-list: [ exp ] [ { , } [ exp ] ]... [ { , } ] { ; } { ; }
2 – USING
The PRINT USING statement generates output formatted according to a format string to a terminal or a terminal-format file. The format string can be numeric or string. Example PRINT USING "$$####.##-", 348832.433, -888.3, .67
2.1 – Syntax
PRINT [ chnl-exp ] USING str-exp { , } output-list { ; } output-list: [ exp ] [ { , } [ exp ] ]... [ { , } ] { ; } { ; }
2.2 – Numeric format
Character Output # Reserves space for one sign or digit. , Inserts commas before every third digit to the left of the decimal point . . Inserts a decimal point. $$ Reserves space for a dollar sign and one digit. ** Fills the left side of the field with asterisks and reserves space for two digits. - Prints negative numbers with a trailing minus sign. ^^^^ Specifies E notation for floating-point numbers. <0> Prints leading zeros instead of spaces. <%> Prints all spaces if the value of the field is zero. <CD> Prints CR (Credit Record) after negative numbers or zero and DR (Debit Record) after positive numbers. _ Forces the next character in the string to be treated as a literal.
2.3 – String format
All string format characters must start with a single quotation mark ('). The quotation mark reserves one character position. Character Output L Reserves one character position and left-justifies the field. R Reserves one character position and right-justifies the field. C Reserves one character position and centers the field. E Reserves one character position and expands the field to hold the entire field.