Difference between revisions of "PRINT"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
Line 14: Line 14:
 
* Positive number values will have a leading and trailing space in a PRINT(leading space reserved for minus sign).
 
* Positive number values will have a leading and trailing space in a PRINT(leading space reserved for minus sign).
 
* To better format number and text data placement use [[PRINT USING]].
 
* To better format number and text data placement use [[PRINT USING]].
 +
* Instead of using the keyword PRINT you can use the question mark (?).
  
  
Line 25: Line 26:
 
:PRINT a$, a ' demonstrates comma in statement
 
:PRINT a$, a ' demonstrates comma in statement
 
:PRINT a$; a ' demonstrates semicolon in statement
 
:PRINT a$; a ' demonstrates semicolon in statement
 +
:? "Hello city!"
  
 
''Returns:''
 
''Returns:''
Line 32: Line 34:
 
:Hello country!      321
 
:Hello country!      321
 
:Hello country! 321
 
:Hello country! 321
 +
:Hello city!
  
  

Revision as of 01:07, 5 October 2009

The PRINT statement prints text, ASCII characters or numbers to the screen.


Syntax: PRINT text_or_number [{;|,}]


  • Text to be printed can be a STRING variable or a value inside of quotation marks.
  • Quotes cannot be inside of the value! Use CHR$(34) to place quotation marks inside of a literal string.
  • PRINT can use semicolons or + concatenation operations in the statements to combine strings and numbers.
  • Semicolon ends stop the print cursor immediately for next data.
  • Use semicolon ends on bottom 2 rows of the SCREEN mode used or the PRINT will roll the screen up.
  • Commas TAB the print cursor for next data. You can use more than one consecutively.
  • Positive number values will have a leading and trailing space in a PRINT(leading space reserved for minus sign).
  • To better format number and text data placement use PRINT USING.
  • Instead of using the keyword PRINT you can use the question mark (?).


Example:

PRINT "Hello world!"
PRINT 123
a$ = "Hello country!"
a = 321
PRINT a$, a ' demonstrates comma in statement
PRINT a$; a ' demonstrates semicolon in statement
? "Hello city!"

Returns:

Hello world!
123
Hello country!      321
Hello country! 321
Hello city!


Explanation:

First PRINT prints the text between the quotation marks, then it prints the value 123, notice that there are no quotation marks when printing the value, quotation marks means that it will be treated like a string of text.

a$ is set to "Hello country" and 'a' is set to the value 321, the dollar sign is used when a variable handles text. The contents of a$ is then printed and the "," means that the value of 'a' is printed seperated by a tab and ";" means that there are no separation from the other text.


See also: CSRLIN, POS, COLOR, LOCATE, CHR$, VIEW PRINT, SCREEN, SPC, SPACE$, INPUT, SCREEN(function)


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage