Jump to content
Developer Wiki and Function Reference Links ×

Write() command doesn't work


Recommended Posts

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?

Link to comment

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

  • Like 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...