Jump to content


Photo

Writing in a Text File.


  • Please log in to reply
9 replies to this topic

#1 pikachu123

pikachu123

    Pika, pika, pikachu!

  • GMC Member
  • 568 posts
  • Version:GM8

Posted 03 April 2011 - 04:23 PM

I'm having a little trouble with text files. Whenever i try and write in it it says "ERROR error opening file for writing" I opened it but its not working plz help. Heres what i did
file_text_write_string(file_text_open_write("AchIE.txt",string(XORencyrpt("global.APi = 1")))
Thanks,
--pikachu123--

Edited by pikachu123, 03 April 2011 - 11:42 PM.

  • 0

#2 ani12321

ani12321

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 03 April 2011 - 05:04 PM

file_text_write_string(file_text_open_write("
AchIE.txt")
,string(XORencyrpt("global.APi = 1"))

You forgot to close bracket in file_text_open_write

Code it's not working becouse you need to set file_text_open_write() in a variable
file=file_text_open_write("AchIE.txt")
file_text_write_string(file,string(XORencyrpt("global.APi = 1"))

Edited by ani12321, 03 April 2011 - 05:10 PM.

  • 0

#3 pikachu123

pikachu123

    Pika, pika, pikachu!

  • GMC Member
  • 568 posts
  • Version:GM8

Posted 03 April 2011 - 05:42 PM

file_text_write_string(file_text_open_write("
AchIE.txt")
,string(XORencyrpt("global.APi = 1"))

You forgot to close bracket in file_text_open_write

Code it's not working becouse you need to set file_text_open_write() in a variable

file=file_text_open_write("AchIE.txt")
file_text_write_string(file,string(XORencyrpt("global.APi = 1"))

I tried that and i still got the smae error. Heres EXACTLY what i did.
if (score >=  global.APiS && global.APi = 0)
                 {
                 var _FILE;
                 _FILE = file_text_open_write("AchIE.txt")
                 XepyhrPoints += global.APiP
                 if global. APiA = 0 {
                             file_text_write_string(_FILE,string(XORencyrpt("global.APi = 1")))
                             alarm[0] = 100
                             APiA = 1
                             }
                 /*DRAWINGSTUFF |
                 }
there might be some typos becuase my game is on a different computer and it doesnt have internet

Edited by pikachu123, 03 April 2011 - 05:45 PM.

  • 0

#4 ani12321

ani12321

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 03 April 2011 - 07:46 PM

Well I see you are using this code in draw event and maybe the error is because of this. So move _FILE = file_text_open_write("AchIE.txt")
in the create event and make sure to change _FILE to FILE(_FILE is only a temp variable). I think it will work.
  • 0

#5 pikachu123

pikachu123

    Pika, pika, pikachu!

  • GMC Member
  • 568 posts
  • Version:GM8

Posted 03 April 2011 - 10:52 PM

thanks so much that works
EDIT:
now im having problems with reading the text file. Here's my code:
CREATE:

FILE = file_text_open_write("AchIE.txt")

FILER = file_text_open_read("AchIE.txt")
APiF = file_text_read_string("AchIE.txt")
APiFILE = string(XORencrypt(APiF))

DRAW:

if (score >= global.APiS && global.APi = 0) && (!APiFILE = "global.APi = 1")
    {
BLABLABLA }
thanks again ani.

Edited by pikachu123, 03 April 2011 - 11:01 PM.

  • 0

#6 ani12321

ani12321

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 04 April 2011 - 12:32 PM

now im having problems with reading the text file

You can not open the same file for reading and writing. To fix this you need to close file and then open it again. So it will be like this:
FILE = file_text_open_read("AchIE.txt")
APiF = file_text_read_string(FILE)//here you will write the id of file you have opened that is FILE 
file_text_close(FILE)//close file
APiFILE = string(XORencrypt(APiF))  
FILE = file_text_open_write("AchIE.txt")//Open it again for writing. Close it when you dont want anymore

Edited by ani12321, 04 April 2011 - 12:33 PM.

  • 0

#7 pikachu123

pikachu123

    Pika, pika, pikachu!

  • GMC Member
  • 568 posts
  • Version:GM8

Posted 05 April 2011 - 01:02 AM

I tried that and it worked, but the draw event thing is having an error "wrong type if argument to unary operator"

if (score >= global.APiS && global.APi = 0) && (!APiFILE = "global.APi = 1")
    {
BLABLABLA

Edited by pikachu123, 05 April 2011 - 01:13 AM.

  • 0

#8 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9322 posts
  • Version:Unknown

Posted 05 April 2011 - 01:04 AM

Also, the argument to file_text_read_string() is NOT the filename, it's the handle obtained with file_text_open_read(). So in your case, it should be FILER.

-IMP ;) :)
  • 0

#9 ani12321

ani12321

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 05 April 2011 - 05:33 AM

I tried that and it worked, but the draw event thing is having an error "wrong type if argument to unary operator"


if (score >= global.APiS && global.APi = 0) && (!APiFILE = "global.APi = 1")
    {
BLABLABLA


if (score >= global.APiS && global.APi = 0) && (APiFILE != "global.APi = 1")
{
BLABLABLA
  • 0

#10 ani12321

ani12321

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 05 April 2011 - 05:34 AM

sorry double post

Edited by ani12321, 05 April 2011 - 05:34 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users