Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management.

isnumber()


Verify that a string is a valid numeric representation.

Syntax

isnumber(variable)

Parameter

Parameter

Definition

variable

string that is to be evaluated as meeting the criteria for a numeric expression

Description

The isnumber() function returns a Boolean value of 1 if variable is a string that is considered valid as a number, or "0" if it is not. 

A valid number contains only digits, periods, or minus signs. White space or any other invalid character anywhere in the string causes the isnumber() function to return 0. The isnumber() function returns 0 for the NULL string.

Example

The following example uses the isnumber() function to examine a list and report which of the elements are numbers:

# +77 is enclosed in quotes to avoid+being interpreted as an operator
list = ["0not",34.2,"16.two",37,94,0.3,-2.8,"+77",nonum];
foreach X (list) {
if (isnumber(X)) {
print(X," is a number.\n");
} else {
print("Sorry, ",X," is not a number.\n");
}
}

 

The example produces the following output:

Sorry, 0not is not a number.
34.2 is a number.
Sorry, 16.two is not a number.
37 is a number.
94 is a number.
0.3 is a number.
-2.800000 is a number.
+77 is a number.

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*