MC-Basic:PRINTUSING

From SoftMC-Wiki
Revision as of 16:00, 13 December 2010 by Arwiebe (talk | contribs) (Created page with '{{MC-Basic |SHORT FORM= PrintU |SYNTAX= PrintUsing “''<format_string>''”;[''<expression>''];{[''<expression>'']}* |AVAILABILITY= All versions |DESCRIPTION= Prints formatte…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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