VAL

Contents


val transforms a character string to a number.

 

Syntax

   val( expr_c )

 

Parameters

Element

Description

Restrictions

expr_c

Alphanumeric expression.

None.

 

Examples

   # The result is 123
    I = val(sum("1", "2", "3"))

   # The result is -111
    val("-111+a111")

   # The result is 10000
    val("10E3")

   # The result is 1e37
    val("1e37")

 

Description and comments

val(expr_c) transforms a character string argument to a number.

expr_c may contain:

- the characters from '0' to '9' inclusive,
- '-' (minus sign),
- '+' (plus sign),
- '.' (decimal point),
- 'e' or 'E' (scientific notation for powers of 10).

Any spaces in the header of expr_c are ignored.

If the string includes an "illegal" character (not included between '0' and '9', etc.), truncation takes place before this character and the truncated string is transformed to a number. If this character is in the 1st position of the string, val returns 0.

The result type is Integer or Decimal as applicable.

 

Associated errors

Error

Description

ERMODE (10)

The argument is not alphanumeric.

 

Associated key words

NUM$


CONTENTS


Copyright © Sage 1999 - 2007