Show / Hide Table of Contents

Class Integer

Integers are positive and negative whole 32-bit unsigned numbers without decimals. If you need to work with decimals, use the Float data type.

Syntax

Constructors

Integer()

Default constructor.

Declaration
Integer Integer()
Returns
Type Description
Integer

Integer(Integer)

Pass a value to copy into a new object.

Declaration
Integer Integer(Integer value)
Parameters
Type Name Description
Integer value

Integer object.

Returns
Type Description
Integer

Integer(String)

Pass a String containing a number. The constructor will parse the text and create an Integer object.

Declaration
Integer Integer(String value)
Parameters
Type Name Description
String value

A String containing a number. For example "13".

Returns
Type Description
Integer
Examples
Integer favOfSheldon = Integer("73");

Methods

abs()

Converts a numeric value to its absolute value (the non-negative value of the number without regarding the sign).

One of the most frequently used methods, typically when you are going to output something.
Declaration
Integer abs()
Returns
Type Description
Integer
Examples
Integer i = -7;
print(i.abs().toString());

isNull()

Returns true if it has no value and false if it does.

Declaration
Bool isNull()
Returns
Type Description
Bool
Remarks

A NULL/NUL/NIL Integer is different from zero, in that it is conceptually without a value. However, when a null Integer is used naively, CRMScript is usually forgiving and interprets it as zero.

Examples
Integer i;
printLine(i.isNull().toString());
i = 0;
printLine(i.isNull().toString());

The 1st output will be true because we haven't initialized ì yet. The next output will be false because i now has the value 0.

toBool()

Converts a numeric value to its boolean representation. Returns false if the integer is zero, otherwise true.

Declaration
Bool toBool()
Returns
Type Description
Bool
Examples
Integer i = 3;
printLine(i.toBool().toString());

toHex()

Converts an Integer to a hexadecimal string.

Declaration
String toHex()
Returns
Type Description
String
Remarks

By default, it converts the value of the current object. You can optionally pass a specific value to convert. (See below)

Examples
printLine("Int \t Hex");
for (Integer i = 0; i < 16; i++) {
	printLine(i.toString() +"\t " + i.toHex());
}

toHex(Integer)

Converts an Integer to a hexadecimal string.

Same as above except you write toHex(i) rather than i.toHex().
Declaration
String toHex(Integer)
Parameters
Type Name Description
Integer value

Integer object. The value to convert to hex.

Returns
Type Description
String

toString()

Converts a numeric value to its string representation.

One of the most frequently used methods, typically when you are going to output something.
Declaration
String toString()
Returns
Type Description
String
Examples
Integer c = 100;
String s = c.toString();
In This Article
  • Constructors
    • Integer()
    • Integer(Integer)
    • Integer(String)
  • Methods
    • abs()
    • isNull()
    • toBool()
    • toHex()
    • toHex(Integer)
    • toString()
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top