Comma: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
TheSnowDog (talk | contribs) m (QBasic capitalisation) Tag: visualeditor |
No edit summary |
||
Line 5: | Line 5: | ||
* Commas in [[PRINT]] statements [[TAB]] space values up to 15 column places with column 57 being the maximum per row. | * Commas in [[PRINT]] statements [[TAB]] space values up to 15 column places with column 57 being the maximum per row. | ||
* A comma following the prompt text in an [[INPUT]] statement does not display a question mark. A [[Semicolon|semicolon]] or no prompt does. | * A comma following the prompt text in an [[INPUT]] statement does not display a question mark. A [[Semicolon|semicolon]] or no prompt does. | ||
* Commas are also used between [[INPUT]] statement variables when more than one input is required. | * Commas are also used between [[INPUT]] statement variables when more than one input is required. | ||
Line 15: | Line 15: | ||
''Example 1:'' Comparing [[TAB]] to [[comma]] tab spacing. | ''Example 1:'' Comparing [[TAB]] to [[comma]] tab spacing. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|PRINT}} {{Cl|TAB}}(15); "T" | {{Cl|PRINT}} {{Cl|TAB}}(15); "T" | ||
{{Cl|PRINT}} , "T" | {{Cl|PRINT}} , "T" | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Line 27: | Line 27: | ||
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 2, 1: {{Cl|PRINT}} value1, value2, value3 | {{Cl|COLOR}} 14: {{Cl|LOCATE}} 2, 1: {{Cl|PRINT}} value1, value2, value3 | ||
{{Cl|COLOR}} 12: {{Cl|LOCATE}} 4, 1: {{Cl|WRITE}} value1, value2, value3 | {{Cl|COLOR}} 12: {{Cl|LOCATE}} 4, 1: {{Cl|WRITE}} value1, value2, value3 | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Revision as of 01:22, 23 January 2023
The comma is used to TAB the cursor after a PRINT statement's text to tab append another printed value.
Usage: INPUT "Name, age and sex(M or F): ", nm$, age%, sex$
- Commas in PRINT statements TAB space values up to 15 column places with column 57 being the maximum per row.
- A comma following the prompt text in an INPUT statement does not display a question mark. A semicolon or no prompt does.
- Commas are also used between INPUT statement variables when more than one input is required.
- LINE INPUT can use a comma or semicolon after the prompt text. Neither will display a question mark.
- Commas are used as argument separators in many kinds of QBasic statements and SUB or FUNCTION parameter lists.
- WRITE statements use commas to separate values printed to the screen or sent to a file without tab spacing them.
- Literal numerical values entered into program code, DATA, files or user INPUT cannot contain comma separators!
Example 1: Comparing TAB to comma tab spacing.
PRINT TAB(15); "T" PRINT , "T" |
Example 2: Comparing PRINT and WRITE statement displays.
value1 = 23567: value2 = 45678: value3 = 354126 COLOR 14: LOCATE 2, 1: PRINT value1, value2, value3 COLOR 12: LOCATE 4, 1: WRITE value1, value2, value3 |
23567 45678 354126 23567,45678,354126 |
- Note: WRITE does not space any values. The commas separate the numerical values without the normal PRINT spacing.
See also: