BlobMid PowerScript function
Description
Extracts data from a blob variable.
Syntax
|
1 |
<span>BlobMid</span> ( <span>data</span>, <span>n</span> {, <span>length</span> } ) |
|
Argument |
Description |
|---|---|
|
data |
Data of the blob datatype |
|
n |
The number (1 to 4,294,967,295) of the |
|
length (optional) |
The number of bytes (1 to 4,294,967,295) |
Return Values
Blob. Returns length bytes from data starting
at byte n. If n is greater
than the number of bytes in data, BlobMid returns
an empty blob. If together length and n add
up to more bytes than the blob contains, BlobMid returns
the remaining bytes, and the returned blob will be shorter than
the specified length. If any argument’s value is null, BlobMid returns null.
Include terminator character
String variables contain a zero terminator, which accounts
for one byte. Include the terminator character when calculating
how much data to extract.
Examples
In this example, the first call to BlobMid stores
10 bytes of the blob datablob starting at position
5 in the blob data_1; the second call
stores the bytes of datablob from position 5 to the end in data_2:
|
1 |
blob data_1, data_2, datablob |
|
1 |
|
1 |
... // Read a blob datatype into datablob. |
|
1 |
|
1 |
data_1 = <span>BlobMid</span>(datablob, 5, 10) |
|
1 |
data_2 = <span>BlobMid</span>(datablob, 5) |
This code 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. Then, using the date’s start position, it
extracts the date from the blob and displays it in the StaticText st_1:
|
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 |
|
1 |
pic_date = Today() |
|
1 |
nbr = <span>BlobEdit</span>(emp_photo, 1, temp) |
|
1 |
<span>BlobEdit</span>(emp_photo, nbr, pic_date) |
|
1 |
st_1.Text = String(Date(BlobMid(emp_photo, nbr))) |