Re: Bad File Mode: Writing To Locked Binary .txt File
This is a follow up to your thread about flat file locking.
However, to answer your question here, you do not need to open the file in Binary mode.
A TXT file, whilst a Binary files (all files are binary when you think about it), is a special case where there should not be any binary data in it such as bitmaps etc.
You need to use the Random clause as outlined in the examples already given as if you open the file for 'OUTPUT' it is deleted first. For 'APPEND', the data is added to the end of the file so that doesn't help.
BINARY mode requires you to PUT or GET from specific byte positions so INPUT # and WRITE # won't work.
The easiest way is to use a RANDOM access file that allows you to read or write anywhere in the file based upon a record number rather than a byte position. This makes handling things much easier in the programming.