Integer PowerScript function
Description
Converts the value of a string to an integer or obtains an
integer value that is stored in a blob.
Syntax
|
1 |
<span>Integer</span> ( <span>stringorblob</span> <span></span>) |
|
Argument |
Description |
|---|---|
|
stringorblob |
A string whose value you want returned |
Return Values
Integer. Returns the value of stringorblob as
an integer if it succeeds and 0 if stringorblob is
not a valid number or is an incompatible datatype. If stringorblob is null, Integer returns null.
Usage
To distinguish between a string whose value is the number
0 and a string whose value is not a number, use the IsNumber function
before calling the Integer function.
Examples
This statement returns the string 24 as an integer:
|
1 |
<span>Integer</span>("24") |
This statement returns the contents of the SingleLineEdit sle_Age as
an integer:
|
1 |
<span>Integer</span>(sle_Age.Text) |
This statement returns 0:
|
1 |
<span>Integer</span>("3ABC") // 3ABC is not a number. |
This example checks whether the text of sle_data is
a number before converting, which is necessary if the user might
legitimately enter 0:
|
1 |
integer li_new_data |
|
1 |
IF IsNumber(sle_data.Text) THEN |
|
1 |
li_new_data = Integer(sle_data.Text) |
|
1 |
ELSE |
|
1 |
SetNull(li_new_data) |
|
1 |
END IF |
After assigning blob data from the database to lb_blob,
this example obtains the integer value stored at position 20 in
the blob:
|
1 |
integer i |
|
1 |
i = <span>Integer</span>(BlobMid(lb_blob, 20, 2)) |
See Also
-
Integer method for
DataWindows in the DataWindow Reference or the online Help