index

Varkon MBS Programmers manual

# ival - Function

## Description

Converts a string of characters to an integer 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

      i:=ival(s, status, nchars);

      int    i;
      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

An INT value equal to the converted integer or zero if conversion was not successful.

## Examples

      i:=ival(" -12345 ");            ! Returns i = -12345

      i:=ival(" ABC ");               ! Returns zero

      i:=ival("12345",status);        ! Retuns i = 12345 and status = 0

      i:=ival("ABC",status);          ! Returns i = 0 and status = -1

      i:=ival("12345 ABC",status,n);  ! Returns i = 12345, status = 0 and n = 5

## See also

fval(), rval()

Varkon version 1.19C svn# 120