Opening filesby Ben (no login)For opening DOS text files: to read files: open "file.txt" for input as #1 do line input #1,s$ 'gets an entire line from file and puts it into s$ loop until eof(1) 'eof function reutrns -1 when end of file is reached close to write to files: will erase everything in the file and start writing: open "file.txt" for output as #1 print #1, "hello" '<prints "hello" in the begining of file close will modify the file adding content to the end of the file (not erasing everything): open "file.txt" for append as #1 print #1,"hello" '<will print "hello" at the end of the file close if you want to modify other files that are not DOS text files then: 'GET filenum,offset,storage dim s as string*2 open "file.bin" for binary as #1 get #1,1,s '<will get the first 2 bytes of the file put #1,33,s'<will put 2 bytes of data into the 33rd byte in the file close I'm not sure how to modify random access files, 'cause I think they are stupid. I suggest you read the QBasic help files, they probably have a better explanation. If you don't have the QBasic help files, download a proper QBasic distribution. Key statements: OPEN PRINT # WRITE # INPUT # LINE INPUT # GET (file) PUT (file) FREEFILE CLOSE |
| Response Title | Author and Date |
| Oh, and if you want to copy files, use the DOS "copy" command in SHELL | Ben on Dec 22 |
| Wow! Random files are stupid? Really? They are similar to Binary.......... | on Dec 22 |