VARKON Version 1.16 1998-09-04


fval - Function

String to float conversion


Description

Converts a string of characters to a float value. Leading blanks are ignored but counted together with the number of characters actually used for conversion. If conversion is not possible a value of zero is returned.

Syntax

fval(str, status, nchars)

STRING str*132;
INT status;
INT nchars;


Principal parameters

str - The string to convert


Optional parameters

status - 0 => Conversion succsessful, -1 => No conversion possible
nchars - Number of characters from str used for conversion


Return value

An FLOAT value equal to the converted float or zero if conversion was unsuccessful.

Example

f:=fval(" -12345 ");

Returns f = -12345.0

f:=fval(" ABC ");

Returns zero.

f:=fval("1.2E3",status);

Retuns f = 1200.0 and status = 0.

f:=fval("ABC",status);

Returns f = 0.0 and sets status to -1.

f:=fval("1.2e-3 ABC",status,n);

Returns f = 0.0012, status = 0 and sets n to 5.

See also

ival() rval()


VARKON Homepage Index