Long

Converts data into data of type long. There are two syntaxes.

To

Use

Combine two unsigned integers into a long value

Syntax 1

Convert a string whose value is a number into a long or to obtain a long value stored in a blob

Syntax 2


Syntax 1: For combining integers

Description

Combines two unsigned integers into a long value.

Syntax

Long ( lowword, highword )

Argument

Description

lowword

An UnsignedInteger to be the low word in the long

highword

An UnsignedInteger to be the high word in the long


Return value

Long.

Returns the long if it succeeds and -1 if an error occurs. If any argument's value is null, Long returns null.

Usage

Use Long for passing values to external C functions or specifying a value for the LongParm property of PowerBuilder's Message object.

Examples

These statements convert the UnsignedIntegers nLow and nHigh into a long value:

UnsignedInt nLow // Low integer 16 bits
UnsignedInt nHigh // High integer 16 bits
long LValue // Long value 32 bits
 
nLow = 12345
nHigh = 0
LValue =  Long(nLow, nHigh)
MessageBox("Long Value", Lvalue)

Syntax 2: For converting strings and blobs

Description

Converts a string whose value is a number into a long or obtains a long value stored in a blob.

Syntax

Long ( stringorblob )

Argument

Description

stringorblob

The string you want returned as a long or a blob in which the first value is the long value. The rest of the contents of the blob is ignored. Stringorblob can also be an Any variable containing a string or blob.


Return value

Long.

Returns the value of stringorblob as a long if it succeeds and 0 if stringorblob is not a valid PowerScript number or if it is an incompatible datatype. If stringorblob is null, Long 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 Long function.

Examples

This statement returns 2167899876 as a long:

Long("2167899876")

After assigning blob data from the database to lb_blob, the following example obtains the long value stored at position 20 in the blob:

long lb_num
lb_num = Long(BlobMid(lb_blob, 20, 4))

For an example of assigning and extracting values from a blob, see Real.

See also

Dec

Double

Integer

LongLong

Real

Long method for DataWindows in the section called “Long” in DataWindow Reference.