Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Problems writing to file  (Read 14510 times)

0 Members and 1 Guest are viewing this topic.

mihaipuiucernea

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 41
  • Currently working on Colors on Canvas
    • View Profile
Problems writing to file
« on: August 26, 2018, 04:15:01 PM »

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: [Select]
on "LeftClick"
  {
UserDescFile.OpenAsText(2);
UserDescFile.SetPosition(0);
UserDescFile.WriteText("1");
UserDescFile.Close();
  }

and in another's entity's script, this code:
Code: [Select]
on "LeftClick"
  {
UserDescFile.OpenAsText(2);
UserDescFile.SetPosition(2);
UserDescFile.WriteText("2");
UserDescFile.Close();
  }
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!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Problems writing to file
« Reply #1 on: August 26, 2018, 04:27:07 PM »

If you want to append stuff to an existing file, you should use OpenAsText(3).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

mihaipuiucernea

  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 41
  • Currently working on Colors on Canvas
    • View Profile
Re: Problems writing to file
« Reply #2 on: August 26, 2018, 04:29:08 PM »

Thank you!

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

Page created in 0.031 seconds with 24 queries.