Raptor:Raptor Printf

From NewEagleWiki
Jump to navigation Jump to search

Return to the main Raptor page

Return to Strings page

Raptor™ Printf

Description

This is used to format numerical or other types of data into a string according to the provided format string. The format string is a standard C format string. A format string can contain both text to be output to the string and format specifiers which are used to output data from another input port to the string. The input ports for this block will be created based on the format string entered in the parameter. To output a % to the output use %%.

A format specifiers has the following form %[flags][width][.precision][length]specifier

Note: Line breaks (newline/char(10), char(13)) must be added using "\n" or "\r". Line breaks and tabs will also not display correctly with a Draw Text block.

Note: Simulink String blocks are not compatible with Raptor blocks. Please use Raptor String blocks.

flags Description
- Left-justify within the given field. Right justification is the default.
+ Forces a plus or minus sign to precede the number. By default, only negative numbers are preceded with a minus sign.
(space) Inserts a blank space before the value if no sign is going to be written.
# Used with o, x or X specifiers the value is preceeded with 0, 0x or 0X respectively for values other than zero.

Used with a, A, e, E, f, F, g or G it forces the output to contain a decimal point even if no more digits follow.

0 Left-pads the number with zeroes instead of spaces.
width Description
(number) Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded. The value is not truncated if the result is larger.
* The width is specified with an additional input port, not in the format string.
.precision Description
.number For d, i, o, u, x and X specifiers, this is the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated if the result is longer.

For a, A, e, E, f and F specifiers, this is the number of digits to be printed after the decimal point. The default value is 6. For g and G specifiers, this is the maximum number of significant digits to be printed. For s: this is the maximum number of characters to be printed.

.* The precision is specified with an additional input port, not in the format string.

The length field modifies the default data type of the incoming port for a specifier.

length specifiers
d i u o x X f F e E g G a A c s
(none) int32 uint32 double uint8 string
hh int8 uint8
h int16 uint16
l uint16
specifier Output Example
d or i Signed integer -189
u Unsigned integer 254
o Unsigned octal 610
x Unsigned hexadecimal integer 7ff
X Unsigned hexadecimal integer (uppercase) 7FF
f Floating point, lowercase 1234.85
F Floating point, uppercase 1234.85
e Scientific notation, lowercase 1.23485e+3
E Scientific notation, uppercase 1.23485E+3
g Use the shortest representation of %e or %f
G Use the shortest representation of %E or %F
a Hexadecimal floating point, lowercase -0xd.32fep-2
A Hexadecimal floating point, uppercase -0XD.32FEP-2
c Character a
s String

Inputs

Input Type Description
string string String Handle
... Signals to put in string

Outputs

Output Type Description
string string Duplicate string handle

Parameters

Parameter Type Description
Format String String Determines how the data is put into the string.