BlobMid

Description

Extracts data from a blob variable.

Syntax

BlobMid ( data, n {, length } )

Argument

Description

data

Data of the blob datatype

n

The number (1 to 4,294,967,295) of the first byte you want returned

length  (optional)

The number of bytes (1 to 4,294,967,295) you want returned


Return value

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:

blob data_1, data_2, datablob
 
... // Read a blob datatype into datablob.
 
data_1 = BlobMid(datablob, 5, 10)
data_2 = BlobMid(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:

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)
st_1.Text = String(Date(BlobMid(emp_photo, nbr)))

See also

Blob

BlobEdit