beautypg.com

Formatfloat (float, formatstring), Syntax, Variable or constant – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 400: Remarks

background image

Section 11. String Functions

FormatFloat (Float, FormatString

)

Converts a floating point value into a string.

Syntax
String = FormatFloat (Float, FormatString)

Remarks
The string conversion of the floating point value is formatted based on the
FormatString. Total field width includes decimal point and sign.

Other ASCII characters can be included in the FormatString.

(example: FormatFloat(Variable,"The current reading is %2.3G")

Parameter
& Data Type

Enter

FORMATFLOAT PARAMETERS

Float
Variable or
constant

The Float parameter is the variable or constant that holds the floating point
value to be converted.

Option
Constant as
String

The FormatString determines how the floating point value will be represented
in the converted string. Note that the format string must be enclosed in quotes.
The options are (m = mantissa; d = decimal; x = exponent):

Option

"%e"

Decimal notation in the form of +m.dddddd e+xx; precision is 6
places to the right of the decimal.

"%f"

Decimal notation in the form of +mmm.dddddd; precision is 6
places to the right of the decimal.

"%g"

Mantissa and decimal are variable; trailing 0s and decimals are
omitted.

"%Y.Zf" Decimal notation in the form of +m.d; precision is defined by Y

places to the left of the decimal and Z places to the right of decimal.

"%Ye"

Decimal notation in the form of +m.d e+xx; precision is defined by
Y characters to the right of the decimal

"%Yg" Mantissa and decimal are variable; precision is defined by Y

InStr (Start, SearchStr, SoughtString, SearchOption )

The InStr instruction is used to find the location of a string within a string.

Syntax
Variable = InStr (Start, SearchString, SoughtString, SearchOption )

Remarks
This instruction returns the integer position of the SoughtString parameter. If
the SoughtString is not found, the instruction returns 0.

11-4