--- In [email protected], "glogic_1" <[EMAIL PROTECTED]> wrote:
>
> Hey all
<snip>
> 
> String filename;
> string FileCompare = {""};
> filename=InputBox("FileOpen",
>     "Enter name of file to Open","");
> 
> ifstream file;
> file.open("AsteroidsSave.txt");
> if(!file)
> {
>   Form1->Canvas->TextOutA(20,300,"UNABLE TO OPEN FILE!!");
> }
> else
> {
>   while(file)
>   {
>     file >> FileCompare;
>     if (filename.c_str() == FileCompare)
>     {
>       Form1->Canvas->TextOutA
>           (20,300,"worked!               " ) ;
>       file >> theShip.points[0].x ;
> 
>     }
>     else
>     {
>       //next line code??
>     }

No "else". The "while" loop should (see next paragraph) continue until
the end of the file is reached; the "file >> FileCompare;" will read
one line at a time. That's it.

The one thing you will have to change is the "while" condition; "file"
itself will never be NULL after having been opened, so you have to
check for the end of the file here. Otherwise you will encounter an
infinite loop here.

> 
>   }//end while
> }
> 
> file.close();

Regards,
Nico

Reply via email to