Jump to content


Photo

freezing when creating file


  • Please log in to reply
5 replies to this topic

#1 Kracker_Kid

Kracker_Kid

    GMC Member

  • GMC Member
  • 235 posts

Posted 09 June 2012 - 07:34 PM

this is the code i use when creating a new file, when one doesnt exist

ini_open("save.ini")
ini_write_real("EXAMPLE","test",1)
ini_close()


now, it creates the file just fine, even puts the correct info into the file, but the program immediately freezes here. is it something i'm doing wrong?

Edited by Kracker_Kid, 11 June 2012 - 11:43 AM.

  • 0

#2 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 09 June 2012 - 09:30 PM

this is the code i use when creating a new file, when one doesnt exist


ini_open("save.ini")
ini_write_real("EXAMPLE","test",1)
ini_close()


now, it creates the file just fine, even puts the correct info into the file, but the program immediately freezes here. is it something i'm doing wrong?


What version of Windows are you using? Win 7 protects the Program Files folders, and it's possible there's something going on there (if you have your file saving in C:\Program Files)

Try, for a test, using the temp_directory option:

ini_open(temp_directory + "save.ini");

If it works, you may have folder permission issues where you are saving the ini file.
  • 0

#3 Kracker_Kid

Kracker_Kid

    GMC Member

  • GMC Member
  • 235 posts

Posted 10 June 2012 - 08:27 AM

What version of Windows are you using? Win 7 protects the Program Files folders, and it's possible there's something going on there (if you have your file saving in C:\Program Files)

Try, for a test, using the temp_directory option:

ini_open(temp_directory + "save.ini");

If it works, you may have folder permission issues where you are saving the ini file.


yes i'm using win 7, but your temp suggestion didnt work :(

this is the only code i'm using in the room, besides setting a timer to go to the next room


if file_exists("save.ini") = 1
{
ini_open("save.ini")
global.example = ini_read_real("XXX","example",1)
ini_close()
}
else
{
ini_open("save.ini")
ini_write_real("XXX","example",1)
ini_close()
}


and as i said, it creates the file fine, it just freezes after it creates it. restarting the game will mean the game doesnt freeze since the file is already created....
  • 0

#4 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 11 June 2012 - 06:24 AM

this is the only code i'm using in the room, besides setting a timer to go to the next room

if file_exists("save.ini") = 1
{
ini_open("save.ini")
global.example = ini_read_real("XXX","example",1)
ini_close()
}
else
{
ini_open("save.ini")
ini_write_real("XXX","example",1)
ini_close()
}

and as i said, it creates the file fine, it just freezes after it creates it. restarting the game will mean the game doesnt freeze since the file is already created....

Just an FYI, you should not need the '= 1' after 'if file_exists("save.ini")'. I don't think it would cause the problem, but I believe it can removed.

Where is this code? Is it being called during a STEP event? If so, it will try to create it multiple times. If not, add a show_message to each section to find out which code is executing before it freezes. The problem probably has an easy solution that hasn't been discovered yet.
  • 0

#5 torigara

torigara

    GMC Member

  • GMC Member
  • 6483 posts

Posted 11 June 2012 - 08:45 AM

Another note is that there is no need to create an ini file on your own. ini_read_real returns the default values (specified by its last argument) when the file doesn't exist. So, you don't have to check the existence of file but execute ini_read functions unconditionally.

As to the problem, the variable global.example isn't set unless the file exists. By any chance isn't it causing the problem? Where do you initialize that variable, and where is its value used?
  • 1

#6 Kracker_Kid

Kracker_Kid

    GMC Member

  • GMC Member
  • 235 posts

Posted 11 June 2012 - 11:38 AM

Another note is that there is no need to create an ini file on your own. ini_read_real returns the default values (specified by its last argument) when the file doesn't exist. So, you don't have to check the existence of file but execute ini_read functions unconditionally.

As to the problem, the variable global.example isn't set unless the file exists. By any chance isn't it causing the problem? Where do you initialize that variable, and where is its value used?


that was it! i wasnt setting global.example to 1 when the file was nonexistant :wallbash:

it would cause an object in the next room to loop forever, its strange because the screen would freeze on this room, and not the next. thanks for spotting that oversight, and i'll use the other advice you provided as well :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users