FMA Posted April 2, 2024 Share Posted April 2, 2024 I have a simple script that intends to read and write into an external text file. The read-part works fine, but I can't get the write function to work, the file always remains unchanged. PROCEDURE TEST; VAR text: ARRAY [1..10000] OF CHAR; filename: STRING; writetext: STRING; BEGIN filename:= 'C:\test.txt'; writetext:= 'hello'; Open(filename); Read(text); message(text[1]); Write(writetext); Close(filename); END; RUN (TEST); Is there something wrong with how I use the write() command? Or might it be due to wrong program permission settings? Quote Link to comment
MullinRJ Posted April 2, 2024 Share Posted April 2, 2024 Hello @FMA, I don't believe you can write to your open READ file. You will need to close it first, and reopen it with Rewrite(), or Append(). Then you can write to it. Rewrite() will write over any existing data, and Append() will add to the end of existing data. Don't forget to close it again when you are finished writing. HTH, Raymond 1 Quote Link to comment
FMA Posted April 3, 2024 Author Share Posted April 3, 2024 That did it, thank You! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.