Difference between revisions of "MC-Basic:PRINTUSING"

From SoftMC-Wiki
Jump to: navigation, search
(chi)
(Fixed double ")
Line 1: Line 1:
{{Languages}}
+
{{Languages|MC-Basic:PRINTUSING}}
  
 
{{MC-Basic
 
{{MC-Basic
Line 6: Line 6:
  
 
|SYNTAX=
 
|SYNTAX=
PrintUsing <''format_string''>;[<''expression''>];{[<''expression''>]}*
+
PrintUsing "<''format_string''>";[<''expression''>];{[<''expression''>]}*
  
 
|AVAILABILITY=
 
|AVAILABILITY=
Line 42: Line 42:
 
|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 #.################;My_Var<br>
+
       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 #.#;1e15<br>
+
       printu "#.#";1e15<br>
  
 
Is printed as<br>
 
Is printed as<br>
Line 51: Line 51:
  
 
While<br>
 
While<br>
       printu #.#;1e16<br>
+
       printu "#.#";1e16<br>
  
 
Is printed as<br>
 
Is printed as<br>
Line 59: Line 59:
 
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 “B is ##.##;B     ‘prints B IS 33.34<br>
+
       PrintU "B is ##.##";B     ‘prints B IS 33.34<br>
       PrintU “B is ##.####;B     ‘prints B IS 33.3440
+
       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)
+
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 “Keep numbers to a fixed length with PrintUsing: ######; 100
+
       PrintU "Keep numbers to a fixed length with PrintUsing: ######" ; 100
  
 
|SEE ALSO=
 
|SEE ALSO=

Revision as of 08:40, 10 August 2017

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

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

See Also