.ModelicaReference.Operators.'String()'

Information

Convert a scalar Real, Integer or Boolean expression to a String representation

Syntax

String(b_expr, minimumLength=0, leftJustified=true)
String(i_expr, minimumLength=0, leftJustified=true)
String(r_expr, significantDigits=6, minimumLength=0, leftJustified=true)
String(r_expr, format)
String(e_expr, minimumLength=0, leftJustified=true)

Description

The arguments have the following meaning (the default values of the optional arguments are shown in the left column):

Boolean b_expr Boolean expression
Integer i_expr Integer expression
Real r_expr Real expression
type e_expr = enumeration(..) Enumeration expression
Integer minimumLength = 0 Minimum length of the resulting string. If necessary,
the blank character is used to fill up unused space.
Boolean leftJustified = true if true, the converted result is left justified;
if false, it is right justified in the string.
Integer significantDigits = 6 defines the number of significant digits in the result string
(e.g., "12.3456", "0.0123456", "12345600", "1.23456E-10")
String format defines the string formatting according to ANSI-C without "%" and "*" character
(e.g., ".6g", "14.5e", "+6f"). In particular:
     format = "[<flags>] [<width>] [.<precision>] <conversion>"
with
<flags> zero, one or more of
"-": left adjustment of the converted number
"+": number will always be printed with a sign
"0": padding to the field width with leading zeros
<width> Minimum field width. The converted number will be printed in a field at
least this wide and wider if necessary. If the converted number has
fewer characters it will be padded on the left (or the right depending
on <flags>) with blanks or 0 (depending on <flags>).
<precision> The number of digits to be printed after the decimal point for
e, E, or f conversions, or the number of significant digits for
g or G conversions.
<conversion> = "e": Exponential notation using a lower case e
= "E": Exponential notation using an upper case E
= "f": Fixed point notation
= "g": Either "e" or "f"
= "G": Same as "g", but with upper case E

Examples

String(2.0)   // = "2.0"
String(true)  // = "true"
String(123, minimumLength=6, leftJustified=false)  // = "   123"

Generated at 2020-06-05T07:38:22Z by OpenModelica 1.16.0~dev-420-gc007a39