• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

file_text_open_write

X

Xenon

Guest
hey guys i'm using a pretty basic code straight from the index and i am getting pretty basic errors, does this have something to do with included files?
Here is the code i am using and the error code supported.
CODE
Code:
var file;
file = get_open_filename(".obj file|*.obj", "");
if file != ""
   {
   file_text_open_write(file);
   file_text_write_string(file, "000010000101000101000001");
   file_text_close(file);
   }
ERROR
Code:
of Key Press Event for <Space> Key
for object obj_vertex:

File not opened for writing.
 at gml_Object_obj_vertex_KeyPressed_SPACE_1 (line 6) -    file_text_write_string(file, "000010000101000101000001");

___________________________________________
############################################################################################
ERROR in
action number 1
of Key Press Event for <Space> Key
for object obj_vertex:

Trying to close unexisting text file.
 at gml_Object_obj_vertex_KeyPressed_SPACE_1 (line 7) -    file_text_close(file);
############################################################################################
 

Humayun

Member
Please try to find solution in manual or already posted threads.
btw read this https://docs.yoyogames.com/source/d...file handling/files/file_text_open_write.html
file is the variable for directory of file that user selected for example i selected "c:\file.txt" then value of "file" will be "c:\file.txt" its not file index. Now you need to create a text file to do so call "var file_index = file_text_open_write(file);" //where file is the name of file. now you can use file_index variable in other file functions like file_text_write_string(file_index, "0101010101010101"); e.t.c
 

PNelly

Member
The docs state that get_open_filename() only grants permissions for reading from a file. I'd guess that because of this the file isn't opened by file_text_open_write(), then isn't written to by file_text_write_string(), and then when you go to close it the system has no idea what file you're talking about because it's not open

What is it exactly that you're trying to do?
 

Humayun

Member
here's correct code:

Code:
var filedir,file;
filedir = get_save_filename(".obj file|*.obj", "");
if filedir != ""
   {
   file = file_text_open_write(filedir);
   file_text_write_string(file, "000010000101000101000001");
   file_text_close(file);
   }
 
Top