BlobEdit

Description

Inserts data of any PowerBuilder datatype into a blob variable.

Syntax

BlobEdit ( blobvariable, n, data {, encoding} )

Argument

Description

blobvariable

An initialized variable of the blob datatype into which you want to copy a standard PowerBuilder datatype

n

The number (1 to 4,294,967,295) of the position in blobvariable at which you want to begin copying the data

data

Data of a valid PowerBuilder datatype that you want to copy into blobvariable

encoding

Character encoding of the blob variable in which you want to insert data of datatype string. Values are:

  • EncodingANSI!

  • EncodingUTF8!

  • EncodingUTF16LE! (default)

  • EncodingUTF16BE!

Returns

Unsigned long. Returns the position at which the next data can be copied if it succeeds, and returns null if there is not enough space in blobvariable to copy the data. If any argument’s value is null, BlobEdit returns null.

If the data argument is a string, the position in the blobvariable in which you want to copy data will be the length of the string + 2. If the data argument is a string converted to a blob, the position will be the length of the string + 1. This is because a string contains a null terminating character that it loses when it is converted to a blob. Thus, BlobEdit (blob_var, 1, "ZZZ'') returns 5, while BlobEdit (blob_var, 1, blob (''ZZZ'') ) returns 4.

Use the encoding parameter if the data argument is a string and you want to generate a blob with a specific encoding.

Examples

Example 1

This example copies a bitmap in the blob emp_photo starting at position 1, stores the position at which the next copy can begin in nbr, and then copies a date into the blob emp_photo after the bitmap data:

blob{1000} emp_photo

blob temp

date pic_date

ulong nbr


... // Read BMP file containing employee picture

... // into temp using FileOpen and FileRead.

pic_date = Today()


nbr = BlobEdit(emp_photo, 1, temp)

BlobEdit(emp_photo, nbr, pic_date)

UPDATEBLOB Employee SET pic = :emp_photo

    WHERE ...

Example 2

This example copies a string into the blob blb_data starting at position 1 and specifies that the blob should use ANSI encoding:

blob{100} blb_data

string str1 = "This is a string"

ulong ul_pos


ul_pos = BlobEdit (blb_data, 1, str1, EncodingANSI!)

See also