Jump to content


Photo

Error Writing To File


  • Please log in to reply
6 replies to this topic

#1 Kaosdachao

Kaosdachao

    GMC Member

  • New Member
  • 109 posts

Posted 25 July 2008 - 07:31 PM

Alright, I'm trying to save a real value to a file but I keep getting errors.

Here's my codes:

Create Event
[codebox]global.write = file_text_open_write("Value")
val = get_integer("Type a Number",0)[/codebox]

Key Pressed F1 Event
[codebox]global.write = file_text_open_write("Value")
file_text_write_real(global.write,val)
file_find_close()[/codebox]

Can anybody explain to me why this isn't working?
  • 0

#2 Kirbya

Kirbya

    GMC Member

  • GMC Member
  • 311 posts

Posted 25 July 2008 - 07:35 PM

You need to add .txt to "Value". So it would be:

global.write = file_text_open_write("Value.txt");
val = get_integer("Type a Number", 0);

  • 0

#3 Kaosdachao

Kaosdachao

    GMC Member

  • New Member
  • 109 posts

Posted 25 July 2008 - 07:46 PM

Alright, now the error message is gone but it still won't write the value to the text document
  • 0

#4 avidnameddavid

avidnameddavid

    Example Maker

  • New Member
  • 771 posts

Posted 25 July 2008 - 07:48 PM

@Kirbya, you do not need to add .txt to the file name. file_text_open_read() treats any file as a text file when opening it, but that does not mean it has to have that extension.

Take out the file_text_open_write() in the F1 event.
file_find_close() is not a function.
  • 0

#5 Kaosdachao

Kaosdachao

    GMC Member

  • New Member
  • 109 posts

Posted 25 July 2008 - 07:57 PM

Well, I took out the file_text_open_write() in the F1 event and got the same result.

Edited by Kaosdachao, 25 July 2008 - 08:18 PM.

  • 0

#6 avidnameddavid

avidnameddavid

    Example Maker

  • New Member
  • 771 posts

Posted 25 July 2008 - 08:29 PM

Let's start over. This script will do everything:
var value, file;

value = get_integer("Enter the number to write:",0);

file = file_text_open_write("Value");

file_text_write_real(file, value);

file_text_close(file);

  • 0

#7 Kaosdachao

Kaosdachao

    GMC Member

  • New Member
  • 109 posts

Posted 25 July 2008 - 08:54 PM

THANK YOU!!! Greatly appreciate the help! I'll make sure I credit you when my game's finished!

Edited by Kaosdachao, 25 July 2008 - 08:55 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users