Previous Next

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. 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 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.
 
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

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.