Wintermute Engine > Technical forum

Problems writing to file

(1/1)

mihaipuiucernea:
Hi guys,

I hve a problem.
So I have a text document, and I want to write stuff in it. The idea is to add some new text in the file, under some conditions. This text will be read later.

So in one entity's script I have this code:

--- Code: ---on "LeftClick"
  {
UserDescFile.OpenAsText(2);
UserDescFile.SetPosition(0);
UserDescFile.WriteText("1");
UserDescFile.Close();
  }

--- End code ---

and in another's entity's script, this code:

--- Code: ---on "LeftClick"
  {
UserDescFile.OpenAsText(2);
UserDescFile.SetPosition(2);
UserDescFile.WriteText("2");
UserDescFile.Close();
  }

--- End code ---
My problem is the following: I click on one entity, close the game and check the text file. Sure enough, there's a number at the specified position. Then I open the game, click the other entity, and while there is the new number at the correct position, the old number is deleted. Is this correct behaviour? Is there any way to make all the text remain in the text document, without being deleted after a new left click?

Thanks guys!

Mnemonic:
If you want to append stuff to an existing file, you should use OpenAsText(3).

mihaipuiucernea:
Thank you!

Should've checked the help file. You rock  ::rock

Navigation

[0] Message Index

Go to full version