TAB: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
m (Removed protection from "TAB")
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
The {{KW|TAB}} function is used in [[PRINT]] and [[LPRINT]] statements to move to a specified column position.
The [[TAB]] function is used in [[PRINT]] and [[LPRINT]] statements to move to a specified column position.




{{PageSyntax}}
{{PageSyntax}}
:{{KW|TAB}}({{Parameter|column%}})
:[[TAB]]({{Parameter|column%}})




Line 12: Line 12:
* [[Comma]] PRINT spacing is up to 15 column places (IE: TAB(15)) to a maximum column of 57.
* [[Comma]] PRINT spacing is up to 15 column places (IE: TAB(15)) to a maximum column of 57.
* When printing to a file, a carriage return([[CHR$]](13)) and linefeed([[CHR$]](10)) character are output when it moves to the next row.
* When printing to a file, a carriage return([[CHR$]](13)) and linefeed([[CHR$]](10)) character are output when it moves to the next row.
* '''Note:''' QBasic did not allow a TAB to be [[concatenation|added]] to a string value. In [[PRINT]] statements the [[+|plus]] would be changed to a [[semicolon]].  
* '''Note:''' QBasic did not allow a TAB to be [[concatenation|added]] to a string value. In [[PRINT]] statements the [[+|plus]] would be changed to a [[semicolon]].
: In QB64, TAB [[concatenation]] is allowed instead of [[semicolon]]s. Example: {{text|PRINT "text" + TAB(9) + "here"|green}}
: In QB64, TAB [[concatenation]] is allowed instead of [[semicolon]]s. Example: {{Text|PRINT "text" + TAB(9) + "here"|green}}




''Example:'' Comparing TAB to [[comma]] print spacing which moves the next text print 15 columns.
''Example:'' Comparing TAB to [[comma]] print spacing which moves the next text print 15 columns.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|PRINT}} {{Cl|TAB}}(15); "T" 'TAB spacing
{{Cl|PRINT}} {{Cl|TAB}}(15); "T" 'TAB spacing


{{Cl|PRINT}} , "T" 'comma spacing
{{Cl|PRINT}} , "T" 'comma spacing


{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{text|;|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'semicolons add nothing to position
{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{Text|;|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'semicolons add nothing to position


{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{text|,|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'comma moves column position beyond 20 '' ''
{{Cl|PRINT}} {{Cl|TAB}}(15); "T"{{Text|,|red}} {{Cl|TAB}}(20); "A"; {{Cl|TAB}}(15); "B" 'comma moves column position beyond 20
{{CodeEnd}}
{{CodeEnd}}
{{OutputStart}}              T
{{OutputStart}}              T
               T
               T
               T    A
               T    A
               B  
               B
               T
               T
                   A
                   A
               B{{OutputEnd}}  
               B{{OutputEnd}}
: ''Explanation:'' TAB moves the PRINT down to the next row when the current column position is more than the TAB position.
: ''Explanation:'' TAB moves the PRINT down to the next row when the current column position is more than the TAB position.



Latest revision as of 22:54, 11 February 2023

The TAB function is used in PRINT and LPRINT statements to move to a specified column position.


Syntax

TAB(column%)


Description

  • Space characters are printed until the print cursor reaches the designated column%, overwriting existing characters.
  • If a subsequent TAB column% is less than the current position, TAB moves the next print to that column on the next row.
  • ASCII CHR$(9) can be substituted for sequencial 9 space column moves.
  • Comma PRINT spacing is up to 15 column places (IE: TAB(15)) to a maximum column of 57.
  • When printing to a file, a carriage return(CHR$(13)) and linefeed(CHR$(10)) character are output when it moves to the next row.
  • Note: QBasic did not allow a TAB to be added to a string value. In PRINT statements the plus would be changed to a semicolon.
In QB64, TAB concatenation is allowed instead of semicolons. Example: PRINT "text" + TAB(9) + "here"


Example: Comparing TAB to comma print spacing which moves the next text print 15 columns.

PRINT TAB(15); "T" 'TAB spacing

PRINT , "T" 'comma spacing

PRINT TAB(15); "T"; TAB(20); "A"; TAB(15); "B" 'semicolons add nothing to position

PRINT TAB(15); "T", TAB(20); "A"; TAB(15); "B" 'comma moves column position beyond 20
              T
              T
              T    A
              B
              T
                   A
              B
Explanation: TAB moves the PRINT down to the next row when the current column position is more than the TAB position.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link