Usage of Blob Data Type

Source: Internet
Author: User

Usage of BLOB Data Type:
Blob {200} bl_var // define an initial size of 200 bytes blob
Blob bl_var // common definition method, zero-length blob
Bl_var = blob (space (200) // dynamically allocates 200 bytes. In fact, a 200 character string is allocated, all of which are spaces (ASCII code 20 h ), finally, it is converted to blob. That is, a 200-byte memory zone is opened, and the content is 20 h instead of 00 H. Work und for all initialization to zero: (is there a more direct method for DX ?)
Blob bl_var
Bl_var = blob (space (200 ))
For I = 1 to Len (bl_var)
Blobedit (bl_var, I, char (0 ))
Next
// BlobEdit () is used to modify the value at the specified position of a blob variable. The modified value can be of any type (converted to blob bytes ).
However, in a strange place, PB regards char as a string. When a non-zero character (char) is written, the string ends with zero, therefore, the two bytes of the blob variable (one is the character itself, and the other is the zero byte) are modified. The solution is Blob (some_char), because when Blob is used to convert the string, only valid characters are converted, and the zero character at the end is ignored. Blob (Char (0) returns a null value, because PB treats char (0) as a zero-length string.
When the modification value is out of the blob variable range, this modification does not take effect!

// The method for processing blob variables byte:
// Bl_source has been initialized, And I is the location of the byte to be processed
Blob {1} bl_byte // declare a single-byte blob
Int li_byte
Bl_byte = BlobMid (bl_source, I, 1) // Extract a byte
Li_byte = ASC (string (bl_byte) // convert to an integer
... // Arbitrary processing of the value of li_byte, within the range of 0-single-byte
// Process the byte content and put it back.
If li_byte = 0 then
Blobedit (bl_source, I, char (0) // write 00 h
Else
Blobedit (bl_source, I, blob (char (li_byte )))
End if

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.