Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : INTEGER function
 

INTEGER function

Converts an expression of any data type, with the exception of BLOB, CLOB, and RAW, to a 32-bit integer value of data type INTEGER, rounding that value if necessary.

Syntax

INTEGER ( expression )
expression
A constant, field name, variable name, or expression. The function behaves as described for the following data types:
*If the value of expression is a CHARACTER, it must be valid for conversion into a number (for example, "1.67" is valid, "1.x3" is not).
*If expression is an object reference (CLASS), the result is the ABL-generated ID for the class instance.
*If expression is a reference to an instance of an enum, the result is the underlying numeric value of that instance. Because the underlying numeric values of enum members are of type INT64, the function may raise an error if the value cannot be represented as an INTEGER.
*If expression is a LOGICAL, the result is 0 if expression is FALSE and the result is 1 if expression is TRUE.
*If expression is a DATE, the result is the number of days from 1/1/4713 B.C. to that day. If expression is the Unknown value (?), 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 CustNum, Address, and converted street number are displayed.
r-intgr.p
DEFINE VARIABLE street-number AS INTEGER NO-UNDO LABEL "Street Number".

FOR EACH Customer NO-LOCK:
  ASSIGN street-number = INTEGER(ENTRY(1, Customer.Address, " ")) NO-ERROR.

  IF ERROR-STATUS:ERROR THEN
    MESSAGE "Could not get street number of" Customer.Address.
  ELSE
    DISPLAY Customer.CustNum Customer.Address street-number.
END.

See also

DECIMAL function, STRING function