Reserved Identifiers
127
NetLinx Programming Language Reference Guide
Keywords & Run-Time Library Functions (Cont.)
FORMAT
Provides a mechanism similar to 'C's
printf
statement for formatting the dis-
play of numbers. This function is similar to
ITOA
but is infinitely more powerful.
CHAR[] FORMAT(CHAR FormatLine[],CHAR Value)CHAR[]
FORMAT(CHAR FormatLine[],WIDECHAR Value)CHAR[]
FORMAT(CHAR FormatLine[],INTEGER Value)CHAR[] FORMAT(CHAR
FormatLine[],SINTEGER Value)CHAR[] FORMAT(CHAR
FormatLine[],LONG Value)CHAR[] FORMAT(CHAR
FormatLine[],SLONG Value)CHAR[] FORMAT(CHAR
FormatLine[],FLOAT Value)CHAR[] FORMAT(CHAR
FormatLine[],DOUBLE Value)
Parameters:
•
FormatLine
: A formatted string of text that defines how the (return) string
should be formatted. The format string contains plain characters and a
conversion specification. Plain characters are copied, as is, directly.
Conversion characters conform to the following format:
%[flags][width][.prec]type
- flags
: Output justification, numeric signs, decimal points, trailing zeros,
octal and hex prefixes. By default, output is right justified. Use a '-' to left justify
as in %-5d.
-
: Causes left justification, padding with blanks
0
: Zeros are used to pad instead of spaces if a field length is given.
+
: Output always begins with + or -.
Blank
: Positive values begin with a blank.
- width
: Minimum number of characters to print. If the output would be less
than this width, it is padded with spaces to be width characters wide. If the
output is larger than width the entire output is provided (i.e. it is not truncated).
- .prec
: Maximum number of characters to print or number of digits to the
right of the decimal point for a float or double type.
- type
: Conversion type:
c
: Value is treated as an integer, and presented as the character with that
ASCII value.
d
: Value is treated as a signed integer, and presented as a decimal number.
f
: Value is treated as a double, and presented as a floating-point number.
o
: Value is treated as a signed integer, and presented as an octal number.
u
: Unsigned integer.
x
: Value is treated as an integer and presented as a hexadecimal number
(with lowercase letters).
X
: Value is treated as an integer and presented as a hexadecimal number
(with uppercase letters).
%
: A literal percent character.
•
Value
: The value to be converted to a string.
The result is a formatted text string.
fTemperature = 98.652
STR = FORMAT('The current temperature is
%3.2f',fTemperature)
// Displays "The current temperature is 98.65"
The table below shows some examples of the output of
FORMAT
for several dif-
ferent format lines and values:
FORMAT
Statement Result of
FORMAT
function
FORMAT('%-5.2f',123.234) '123.23'
FORMAT('%5.2f',3.234) '3.23'
FORMAT('%+4d',6) '+6'
Summary of Contents for NETLINX PROGRAMMING LANGUAGE
Page 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Page 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Page 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Page 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Page 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Page 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Page 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Page 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Page 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Page 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...