Cicode Programming Reference > Cicode Function Categories > String Functions Introduction > StrToValue

StrToValue

Converts a string into a floating-point number. This function is similar to the StrToReal() function except that the function halts if it is passed an empty or invalid string. The function will search the string for the first non-blank character, and then start converting until it finds the end of the string or a non-numeric character. If the first non-blank character is not a numeric character (0-9), a space, a decimal point, a " +" or a " - " sign, the function will halt.

Use this function to check keyboard input from the operator by setting control points (for example, it minimizes the likelihood of a setpoint being set to 0 if the operator presses ENTER or enters invalid data by mistake).

Syntax

StrToValue(String)

String:

The string to convert.

Return Value

A floating-point number (converted from String).

Related Functions

StrToReal, StrToInt

Example

System Keyboard

Key Sequence

F3 ######## Enter

Command

SP123 = StrToValue(Arg1);

Comment

Set setpoint 123 to value unless value is invalid

Note: The Cicode is halted. Any other Cicode after the StrToValue() function will not execute.

See Also

String Functions