Author Topic: While loop Crash  (Read 391 times)

Hi,
I have recently been experimenting with text files but this bit of code, when executed, just crashes the game.

Code: [Select]
function testFO()
{
   %fo = new FileObject();
   %fo.openForRead("config/test.cs");
   
   while(!%fo.isEOF)
   {
      %line = %fo.readLine();
     
      echo(%line);
   }
   %fo.close();
   %fo.delete();
}

Could someone please explain what is wrong with this?

Code: [Select]
function testFO()
{
   %fo = new FileObject();
   %fo.openForRead("config/test.cs");
  
   while(!%fo.isEOF())
   {
      %line = %fo.readLine();
      
      echo(%line);
   }
   %fo.close();
   %fo.delete();
}

You were missing "()" after "isEOF" which made it instead search for it as a variable. And since that never exists, it continuously loops forever.
« Last Edit: December 20, 2010, 05:28:37 AM by MegaScientifical »