File read/write function Parsing

Source: Internet
Author: User

Freefile function: automatically obtains an idle file number.
Freefile has optional parameters
Freefile (0) returns 1-255;
Freefile (1) returns 256-511

Open the file in binary mode.
Open pfilename for binary as # filenumber

Open the file randomly.
Open pfilename for random as # filenumber

Open the file in write mode.
Open pfilename for output as # filenumber

Open the file as a read.
Open pfilename for input as # filenumber

Open the file with two file numbers. You can read and write the two file numbers at the same time.
Open pfilename for output as # filenumber1
Open pfilename for input as # filenumber2

Close file
Close # filenumber

Obtain the object length.
Lof (filenumber)

Object read/write pointer to the end
EOF (filenumber)

Obtains the current position of the file read/write pointer.
LOC (filenumber)

Set the file read/write pointer to the position specified by START.
Seek filenumber, start

Note: Code A is less efficient than code B in the following code.
If your program is editing a file, you can:
1. Keep the file open until it is closed upon exit. This method saves memory and is efficient, but may lose data.
2. Read all the file information to the memory, and write all the information when exiting. This method is safe, memory consumption, and efficient.
3. enable one read at a time. This method is safer, saves memory, and has the worst efficiency.

Code
For Index = 0 to 100
Open filename for binary as # FN
Get # FN, index, byte
Close # FN
Next

Code B
Open filename for binary as # FN
For Index = 0 to 100
Get # FN, index, byte
Next
Close # FN

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.