Binary File Reading in Pb (original)

Source: Internet
Author: User

The author needs to process the DBF file data when developing an application system. In Pb, only the data formats of dbaseii and dbaseiii are supported, and the updated version is not supported. Therefore, you need to program your own processing. During programming, you may encounter read/write operations on binary files. For example, read files in the following format by byte and convert them to decimal characters.

AA 00 56 00 bb cc dd ee ff ......

CodeThis is probably the case:

Integer li_filenum, loops, I, K, L
Long FLEN, bytes_read, new_pos
Blob B, tot_ B, B1

Setpointer (hourglass !)
FLEN = filelength ("C:/file1.dat ")
Li_filenum = fileopen ("C:/file1.dat ",&
Streammode !, Read !, Lockread !)
If FLEN> 32765 then
If Mod (FLEN, 32765) = 0 then
Loops = FLEN/32765
Else
Loops = (FLEN/32765) + 1
End if
Else
Loops = 1
End if
New_pos = 1
For I = 1 to Loops
Bytes_read = fileread (li_filenum, B)
Tot_ B = tot_ B + B
Next
Fileclose (li_filenum)

L = Len (tot_ B)
For I = 1 to L
B1 = blobmid (tot_ B, I, 1)
K = ASC (string (B1 ))
Sle_1.text + = string (k) + ":"
Next

Display: 170: 0: 86: 0: 187: 187: 204: 221: 238: 255:

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.