BlobEdit PowerScript function
Description
Inserts data of any PowerBuilder datatype into a blob variable.
Syntax
|
1 |
<span>BlobEdit</span> ( <span>blobvariable</span>, <span>n</span>, <span>data</span> {, <span>encoding</span>} ) |
|
Argument |
Description |
|---|---|
|
blobvariable |
An initialized variable of the blob datatype |
|
n |
The number (1 to 4,294,967,295) of the |
|
data |
Data of a valid PowerBuilder datatype |
|
encoding |
Character encoding of the blob variable
|
Return Values
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, returns 5, while
"ZZZ'')BlobEdit returns 4.
(blob_var, 1, blob (''ZZZ'')
)
Use the encoding parameter if the data argument
is a string and you want to generate a blob with a specific encoding.
Examples
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:
|
1 |
blob{1000} emp_photo |
|
1 |
blob temp |
|
1 |
date pic_date |
|
1 |
ulong nbr |
|
1 |
|
1 |
... // Read BMP file containing employee picture |
|
1 |
... // into temp using FileOpen and FileRead. |
|
1 |
pic_date = Today() |
|
1 |
|
1 |
nbr = <span>BlobEdit</span>(emp_photo, 1, temp) |
|
1 |
<span>BlobEdit</span>(emp_photo, nbr, pic_date) |
|
1 |
UPDATEBLOB Employee SET pic = :emp_photo |
|
1 |
WHERE ... |
This example copies a string into the blob blb_data starting
at position 1 and specifies that the blob should use ANSI encoding:
|
1 |
blob{100} blb_data |
|
1 |
string str1 = "This is a string" |
|
1 |
ulong ul_pos |
|
1 |
|
1 |
ul_pos = BlobEdit (blb_data, 1, str1, EncodingANSI!) |