Difference between revisions of "MC-Basic:PRINTUSING"
(print #1,"" '''''emits \0 (zero character)''''') |
|||
(11 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Languages|MC-Basic:PRINTUSING}} | ||
{{MC-Basic | {{MC-Basic | ||
|SHORT FORM= | |SHORT FORM= | ||
Line 4: | Line 5: | ||
|SYNTAX= | |SYNTAX= | ||
− | PrintUsing | + | PrintUsing "<''format_string''>";[<''expression''>];{[<''expression''>]}* |
|AVAILABILITY= | |AVAILABILITY= | ||
Line 40: | Line 41: | ||
|LIMITATIONS= | |LIMITATIONS= | ||
Only 15 digits after the decimal point can be displayed. The statement, <br> | Only 15 digits after the decimal point can be displayed. The statement, <br> | ||
− | printu | + | printu "#.################";My_Var<br> |
Only prints 15 digits, and not 16 as specified by the format string. Only 16 digits before the decimal point are displayed. The statement:<br> | Only prints 15 digits, and not 16 as specified by the format string. Only 16 digits before the decimal point are displayed. The statement:<br> | ||
− | printu | + | printu "#.#";1e15<br> |
Is printed as<br> | Is printed as<br> | ||
Line 49: | Line 50: | ||
While<br> | While<br> | ||
− | printu | + | printu "#.#";1e16<br> |
Is printed as<br> | Is printed as<br> | ||
− | 1.0e16 | + | 1.0e16<br> |
+ | |||
+ | print #1,"" '''''emits \0 (zero character)''''' | ||
|EXAMPLE= | |EXAMPLE= | ||
Specify a minimum number of characters to print by using the “#” sign and decimal point.<br> | Specify a minimum number of characters to print by using the “#” sign and decimal point.<br> | ||
B = 33.344<br> | B = 33.344<br> | ||
− | PrintU | + | PrintU "B is ##.##";B ‘prints B IS 33.34<br> |
− | PrintU | + | PrintU "B is ##.####";B ‘prints B IS 33.3440 |
− | PrintU | + | PrintU "B is ##.##^^^^";B ‘prints B IS 3.33e+01 (you must use exactly four ^s for this format to work) |
Another example:<br> | Another example:<br> | ||
− | PrintU "The number is #;j1,j2<br> | + | PrintU "The number is #";j1,j2<br> |
à The number is 1, The number is 2 | à The number is 1, The number is 2 | ||
Specifying the number of digits to print, prints data in tabular form since the number of places printed does not vary with the value of the number:<br> | Specifying the number of digits to print, prints data in tabular form since the number of places printed does not vary with the value of the number:<br> | ||
− | PrintU | + | PrintU "Keep numbers to a fixed length with PrintUsing: ######" ; 100 |
|SEE ALSO= | |SEE ALSO= | ||
− | * [[ | + | * [[MC-Basic:CLOSE|CLOSE]] |
− | * [[ | + | * [[MC-Basic:INPUT$|INPUT$]] |
− | * [[ | + | * [[MC-Basic:LOC|LOC]] |
− | * [[ | + | * [[MC-Basic:OPEN|OPEN]] |
− | * [[ | + | * [[MC-Basic:PRINT HASH|PRINT HASH]] |
− | * [[ | + | * [[MC-Basic:PRINTUSING hash-sign|PRINTUSING hash-sign]] |
}} | }} |
Latest revision as of 12:26, 17 August 2020
Language: | English • 中文(简体) |
---|
Prints formatted numeric variables, using the specified format string. The format string contains literal text to be printed, as well as characters for formatting numeric expressions. The following characters can be used formatting numeric expressions:
# digital position
. decimal position
+ prints the sign of the expression
^^^^ prints in exponential format
Only a single formatting string (containing text and formatting characters) followed by the expressions to print is allowed.
Short form
PrintU
Syntax
PrintUsing "<format_string>";[<expression>];{[<expression>]}*
Availability
All versions
Type
<format_string>: String
<expression>: Long, Double or String
Scope
Configuration, Task or Terminal
Limitations
Only 15 digits after the decimal point can be displayed. The statement,
printu "#.################";My_Var
Only prints 15 digits, and not 16 as specified by the format string. Only 16 digits before the decimal point are displayed. The statement:
printu "#.#";1e15
Is printed as
100000000000000.0
While
printu "#.#";1e16
Is printed as
1.0e16
print #1,"" emits \0 (zero character)
Examples
Specify a minimum number of characters to print by using the “#” sign and decimal point.
B = 33.344
PrintU "B is ##.##";B ‘prints B IS 33.34
PrintU "B is ##.####";B ‘prints B IS 33.3440
PrintU "B is ##.##^^^^";B ‘prints B IS 3.33e+01 (you must use exactly four ^s for this format to work)
Another example:
PrintU "The number is #";j1,j2
à The number is 1, The number is 2
Specifying the number of digits to print, prints data in tabular form since the number of places printed does not vary with the value of the number:
PrintU "Keep numbers to a fixed length with PrintUsing: ######" ; 100