Formatters

21.09.2021

Formatters control the output of numbers, angles, strings, calendar time values and timespans. They always start with a '%' character, which is followed by a code, such as %5.3g.

Standard Formatters

The standard formatters %? and %&? output any data types in a standard format. Floating point values are output using a number of valid places that can be set on the General tab in the Properties dialog box of the FlexPro project database. If you use a variant with the & character, data with a unit is output with the unit appended.

Numerical Value

This formatter controls how numerical data is displayed. You can choose from a variety of formatting options. You can align the digits in a field, specify whether an exponent should be displayed and if so, in which format and basis, specify the number of places after the decimal point, and much more.

Syntax

%[Attribute][Field size][.Places]Formatter

The syntax of the numerical value formatter consists of the following elements:

Element

Description

Attribute

One or more of the following attribute characters:

0

Fills up the field size with leading zeros.

&

Outputs quantities with an appended unit.

#

Outputs the decimal separator even if no fractional digits are output.

+ or space

+ also outputs the positive polarity sign. A space outputs a space instead of +.

-

Places the formatted number aligned to the left and fills the remaining field width with spaces.

'

Outputs and groups the integral part of the number using the 1000th separator for easier legibility.

[Invalid]

Replaces the question mark usually output for void values with the text specified in square brackets.

Field size

Specifies with size (width) of the field into which the formatted number is to be placed as either left or right aligned. If necessary, it is filled with spaces. The entire number is always output, even if the Field size was not specified or a smaller size was specified. If applicable, the appended unit is ignored for the alignment and is instead placed after the aligned numerical value.

Places

Depending on the formatter chosen, this selects the number of valid places or fractional digits. If you omit the element, the value preset on the General tab of the project database Properties dialog box is used.

Formatter

f

Never includes the exponent.

E, e *

Always includes the mantissa and exponent.

G, g *

An exponent is only used if it leads to a more compact presentation.

N, n *

An exponent to the base e is always output.

B, b *

An exponent to base 2 is always output.

M, m *

If the mantissa equals 1, then only the exponent is output without the mantissa. Otherwise, only the mantissa is output without the exponent. This display is suited for scaling logarithmic axes, for instance.

F

Instead of an exponent, an SI prefix is appended, e.g. 1.234 k instead of 1.234 E+003.

x, X

Output as integer in hexadecimal system with lower case (x) or upper case (X) letters.

d

Output as integer in dual system.

i

Output as integer in decimal system. Use this formatter instead of %f to output large 64-bit integer values in full resolution.

* Use lower case letters to output the exponent in superscript. Example: 10³ or 2³. Otherwise, E+003 or B+003 will be output, for instance.

Indexed Text

This formatter offers you the option of assigning texts to numerical values starting at 0, which are then displayed instead of the numbers. You can thus label the columns of a column chart, for instance, with individual text. Do not confuse this formatter with the string formatter, which cannot display any numerical data.

Syntax

%("Text0"[, "Text1"[, ..., "Textn"]])

The syntax of the formatter for indexed text consists of the following elements:

Element

Description

Text0 ... Textn

The text to be output instead of the values 0 through n.

Calendar Time

FlexPro saves calendar times (date and time) as numerical values that contain the number of seconds since January 1, 1970 in "Universal Time Coordinated" (UTC). Using a calendar time formatter, you can display these numerical values as a calendar time. FlexPro converts the UTC values automatically to the time zone set in Windows Regional and Language Options. You can, however, specify an option that is to result in output in universal time coordinated. The formatter specifies which time value elements should be displayed. There is a corresponding formatting element for each of the elements listed below. This formatting element starts with a % character. You can write any text between the individual formatting elements, where a percent sign has to be entered as %%.

Syntax

%[.Fractional digits]([UTC] Date)

The syntax of the calendar time formatter consists of the following elements:

Element

Description

Fractional digits

Selects the maximum number of fractional digits for seconds. If you omit the element, then the default value used is 6, which is equivalent of a 1µs resolution.

UTC

Outputs the date as Universal Time Coordinated (UTC).

Date

Any text in which the following element formatters can be embedded:

Name of the day of the week, abbreviated

%a

Name of the day of the week

%A

Name of the month, abbreviated

%b

Name of the month

%B

Date and time, based on Windows Region and Language Options settings

%c

Day of the month in decimal format (00 - 31)

%d

Hour in 24-hour format (00 - 23)

%H

Hour in 12-hour format (01 - 12)

%I

Day of the year as a decimal number (001 - 366)

%j

Month as a decimal number (01 - 12)

%m

Minute as a decimal number (00 - 59)

%M

A.M./P.M. indicator, based on Windows Region and Language Options settings

%p

A.M./P.M. indicator

%P

Second as a decimal number (00 - 59)

%S

Calendar week, starting with Sunday, as a decimal number
(00 - 53)

%U

Calendar week, starting with Monday, as a decimal number
(00 - 53)

%W

Day of the week as a decimal number (0 - 6; Sunday is 0)

%w

Date, based on Windows Region and Language Options settings

%x

Time, based on Windows Region and Language Options settings

%X

Year, two-digit, as a decimal number (00 - 99)

%y

Year, four-digit, as a decimal number (00 - 99)

%Y

Name of the time zone, abbreviated

%z

Name of the time zone

%Z

Percent sign

%%

Examples

%(%A, the %th of %B %Y %H:%M)

An example of this output would be: "Tuesday, the 16th of February 2010 17:15".

%(UTC%A, the %th of %B %Y %H:%M UTC)

An example of this output would be: "Tuesday, the 16th of February 2010 04:15:00 PM"

%.0(%H:%M:%S) or %.0(%X)

Outputs only the time, so the seconds are output without fractional digits.

Timespan

Timespans can be formatted as H:M:S or D:H:M:S . The number of fractional digits as well as the number of places for the hour or day can be adjusted.

Syntax

%[Places][.Fractional digits]Formatter

The syntax of the timespan formatter consists of the following elements:

Element

Description

Places

Specifies the number of digits for the day or hours. If necessary, it is filled with leading zeros.

Fractional digits

Selects the maximum number of fractional digits for seconds. If you omit the element, then the default value used is 6, which is equivalent of a 1µs resolution.

Formatter

t

Output as H:M:S.

T

Output as D:H:M:S.

Examples

%3.2t

Formats the timespan as HHH:MM:SS.ss.

%.0T

Formats the timespan as D:HH:MM:SS. The seconds are output without fractional digits.

Angle

Angles can be displayed in degrees, minutes, seconds (°  ´  ´´) or as a fraction of π. The existing angle data can be formatted in degrees or radians.

Syntax

%[.Places]Formatter

or

%[.Denominator]Formatter

The syntax of the angle formatter consists of the following elements:

Element

Description

Places

When outputting in degrees, minutes, seconds, the maximum number of digits is specified for the seconds. If you omit the element, the default value 6 is used.

Denominator

Outputting as a fraction of π specifies the denominator of the fraction. If you omit the element, then instead of outputting a fraction, a decimal number with the maximum number of fractional digits predefined on the General tab of the project database Properties is output.

Formatter

r, R

Outputs degrees, minutes, seconds.

p, P

Outputs a fraction of π.

Use upper case letters if the data to be formatted is in radians (0 to 2 π) and lower case letters if the data is in degrees (0 to 360).

Examples

%.2r

An example of this output would be: "15° 12´ 24,34´´".

%.4P

An example of this output would be: "3/4 π".

%P

An example of this output would be: "0.75 π".

String

You can limit strings to a maximum length or fill them up to a minimum length. The text can be displayed as left or right justified.

Syntax

%[-][MinFieldSize][.MaxFieldSize]s

or

%[-][MinFieldSize][.MaxFieldSize]S

The syntax of the string formatter consists of the following elements:

Element

Description

-

If specified, the field alignment is left-justified; otherwise, it is right-justified.

MinFieldSize

Specifies the minimum field size in characters. The value is only relevant if the string is shorter than the specified value. It is then filled with spaces.

MaxFieldSize

Specifies the minimum field size in characters. The value is only relevant if the string is longer than the specified value. Excess characters are then cut off.

Formatter

S

Output with double '\' character. This prevents the '\' character in the text from being interpreted as the start symbol in control sequences, such as '\B' for bold.

s

Output unchanged. Control sequences are interpreted and taken into account in the text formatting.

Examples

%s

An example of this output would be: "Test".

%.3s

An example of this output would be: "Tes".

%6s

An example of this output would be: " Test".

Special Format

The following special formats are suitable in particular for numbering in tables and for chapter titles in documents.

Syntax

%Formatters

The syntax of the special format formatter consists of the following elements:

Element

Description

Formatters

a, A

Alphabetical numbering with upper or lower case letters.

o, O

Roman numeral with upper or lower case letters.

c, C

Chinese number, normal or accounting.

j

Japanese Number.

Examples

%a

1, 2, 3, 4 is formatted as a, b, c, d.

%A

1, 2, 3, 4 is formatted as A, B, C, D.

%o

1, 2, 3, 4 is formatted as i, ii, iii, iv.

%O

1, 2, 3, 4 is formatted as I, II, III, IV.

%c

1, 2, 3, 4 is formatted as 一, 二, 三, 四.

%C

1, 2, 3, 4 is formatted as 壹, 贰, 叁, 肆.

%j

1, 2, 3, 4 is formatted as 一, 二, 三, 四.

 

You might be interested in these articles