index

Varkon MBS Programmers manual

# fval - Function

## Description

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

## Syntax

      f:=fval(s, status, nchars);

      float  f;
      string s;
      int    status;
      int    nchars;

## Principal parameters

s | - The string to convert.

## Optional parameters

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

## Return value

A FLOAT value equal to the converted float or zero if conversion was not successful.

## Examples

      f:=fval(" -12345 ");            ! Returns f = -12345.0

      f:=fval(" ABC ");               ! Returns 0.0

      f:=fval("1.2E3",status);        ! Retuns f = 1200.0 and status = 0

      f:=fval("ABC",status);          ! Returns f = 0.0 and status = -1

      f:=fval("1.2e-3 ABC",status,n); ! Returns f = 0.0012, status = 0 and n = 6

## See also

ival(), rval()

Varkon version 1.19C svn# 120