isInteger Method

Class: String

Description

This method indicates whether the value of the data stored in a String object is an integer. An integer is a sequence of one or more digits, possibly preceded by a minus sign. A leading plus sign is not allowed for integers. Leading zeros are not acceptable.

Syntax

StringObject.isInteger()

Parameters

None.

Returns

A Boolean:

1 if the string is an integer.
0 if the string is not an integer.

When Became Available

v6.4

Example

// non integer, even though it has a non zero interpretation

type String NON = "123ABC"

type Boolean B = NON.isInteger()  // 0

 

// non integers:

set NON = " 123 "                 // leading, trailing spaces

set B = NON.isInteger()           // 0

set NON = "12E3"                  // exponent not allowed

set B = NON.isInteger()           // 0

set NON = "+123"                  // plus sign not allowed

set B = NON.isInteger()           // 0

set NON = "0123"                  // leading zero not allowed

set B = NON.isInteger()           // 0

 

type String INT = "-123"          // finally!

type Boolean BI = INT.isInteger() // 1