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?
Error Writing To File
Started by Kaosdachao, Jul 25 2008 07:31 PM
6 replies to this topic
#1
Posted 25 July 2008 - 07:31 PM
#2
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);
#3
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
#4
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.
Take out the file_text_open_write() in the F1 event.
file_find_close() is not a function.
#5
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.
#6
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);
#7
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 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











