Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## INTEGER function

> Converts an expression of any data type to an integer value, rounding that value if necessary.

> #### Syntax

>     INTEGER ( expression )

> ``expression``

> A constant, field name, variable name, or expression whose value can be of any data type. If the value of `expression` is character then it must be valid for conversion into a number (for example, “1.67" is valid, “1.x3" is not). If `expression` is logical, then the result is 0, if `expression` is FALSE, and 1, if `expression` is TRUE. If `expression` is a date, then the result is the number of days from 1/1/4713 B.C. to that day. If the value of `expression` is the Unknown value (`?`), then the result is the Unknown value (`?`).

> Example

> This procedure takes the first word (that is, the substring that precedes the first space character) from the customer address and tries to convert it to an integer (street-number). If the conversion fails (for example, the first word contains non-numeric characters) the procedure displays an error message. Otherwise the cust-num, address, and converted street number are displayed.

> r-intgr.p
>     DEFINE VARIABLE street-number AS INTEGER LABEL "Street Number".

>     FOR EACH customer:
>        ASSIGN street-number = INTEGER(ENTRY(1, address, " ")) NO-ERROR.

>        IF ERROR-STATUS:ERROR
>        THEN MESSAGE "Could not get street number of" address.
>        ELSE DISPLAY cust-num address street-number.
>     END.

> #### See also

> DECIMAL function, STRING function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095