Central Games Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

file_text_open_read("filename.txt") is Failing

4 posters

Go down

file_text_open_read("filename.txt") is Failing Empty file_text_open_read("filename.txt") is Failing

Post by Luke(ADMIN) Thu Jul 24, 2008 3:39 pm

This command is failing. I mean, it won't actually open the file. Here is what I have:

f=file_text_open_read("file.txt")
show_message(string(f))

The show_message command is returning the file number -1 for some reason. Only positive numbers
Luke(ADMIN)
Luke(ADMIN)
Admin
Admin

Male
Number of posts : 838
Age : 30
Location : Right Behind You
Job/hobbies : Hello! I am a programmer/hacker. I play piano and French Horn. I love mountain biking and kayaking.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue999 / 100999 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-17

http://www.lujosoftware.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by SoulRed12 - Moderator Thu Jul 24, 2008 3:50 pm

file_text_open_read() doesn't actually read the file. It only opens the file and returns an identifier that can be used in file_text_read_string/real. If you want to read from the file and show it on the screen, you could do something like this:

Code:
f=file_text_open_read("file.txt");
data=file_text_read_string(f); //Give this function your identifier variable
show_message(data);
file_text_close(f); //Always remember to close your files!

There is such a thing as file_text_read_real and file_text_write_real, but I advise using only strings because you can easily convert them to real numbers using real().
SoulRed12 - Moderator
SoulRed12 - Moderator
Admin
Admin

Male
Number of posts : 428
Age : 33
Location : USA
Job/hobbies : Music, psychology, programming, acting, basketball, and martial arts.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue100 / 100100 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-19

http://soulred12.wordpress.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by Luke(ADMIN) Thu Jul 24, 2008 3:51 pm

I know all that, but it won't actually open the file for reading. It returns a negative integer, which is not correct. The program is not using the command correctly
Luke(ADMIN)
Luke(ADMIN)
Admin
Admin

Male
Number of posts : 838
Age : 30
Location : Right Behind You
Job/hobbies : Hello! I am a programmer/hacker. I play piano and French Horn. I love mountain biking and kayaking.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue999 / 100999 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-17

http://www.lujosoftware.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by SoulRed12 - Moderator Thu Jul 24, 2008 3:56 pm

file_text_open_read() returns -1 when the file with the specified filename does not exist.
SoulRed12 - Moderator
SoulRed12 - Moderator
Admin
Admin

Male
Number of posts : 428
Age : 33
Location : USA
Job/hobbies : Music, psychology, programming, acting, basketball, and martial arts.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue100 / 100100 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-19

http://soulred12.wordpress.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by Luke(ADMIN) Thu Jul 24, 2008 3:59 pm

But it does exist...

I will double check
Luke(ADMIN)
Luke(ADMIN)
Admin
Admin

Male
Number of posts : 838
Age : 30
Location : Right Behind You
Job/hobbies : Hello! I am a programmer/hacker. I play piano and French Horn. I love mountain biking and kayaking.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue999 / 100999 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-17

http://www.lujosoftware.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by Luke(ADMIN) Thu Jul 24, 2008 4:17 pm

hehe, yeah. It tried to open a file that didn't exist
Luke(ADMIN)
Luke(ADMIN)
Admin
Admin

Male
Number of posts : 838
Age : 30
Location : Right Behind You
Job/hobbies : Hello! I am a programmer/hacker. I play piano and French Horn. I love mountain biking and kayaking.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue999 / 100999 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-17

http://www.lujosoftware.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by awasteoflife Sun Aug 03, 2008 11:07 am

you could also use file_text_open_write() as it will create it if it doesnt exist

awasteoflife
Junior Member
Junior Member

Male
Number of posts : 174
Age : 30
Location : My house
Job/hobbies : Prohramming, Gaming and Paperrounds
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue3 / 1003 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-25

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by mrsmes Wed Aug 20, 2008 9:33 am

and how u place information it is done how?

mrsmes
Newbie
Newbie

Number of posts : 13
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-08-20

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by SoulRed12 - Moderator Wed Aug 20, 2008 2:16 pm

mrsmes wrote:and how u place information it is done how?
Please make your own thread for new questions.

But to answer, you must use file_text_write_string() or file_text_write_real(). Check the GM Manual for more info.
SoulRed12 - Moderator
SoulRed12 - Moderator
Admin
Admin

Male
Number of posts : 428
Age : 33
Location : USA
Job/hobbies : Music, psychology, programming, acting, basketball, and martial arts.
Warning :
file_text_open_read("filename.txt") is Failing Left_bar_bleue0 / 1000 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Reputation :
file_text_open_read("filename.txt") is Failing Left_bar_bleue100 / 100100 / 100file_text_open_read("filename.txt") is Failing Right_bar_bleue

Registration date : 2008-07-19

http://soulred12.wordpress.com

Back to top Go down

file_text_open_read("filename.txt") is Failing Empty Re: file_text_open_read("filename.txt") is Failing

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum