Long

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

To

Use

Combine two unsigned integers into a long value

Syntax 1 For combining integers

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

Syntax 2 For converting strings and blobs


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

Returns

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

Example 1

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.

Returns

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

Example 2

This statement returns 2167899876 as a long:

Long("2167899876")

Example 3

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