// default fileme.dir() + "read-str.txt" => string filename; // look at command lineif( me.args() > 0 ) me.arg(0) => filename; // instantiateFileIO fio; // open a filefio.open( filename, FileIO.READ ); // ensure it's okif( !fio.good() ){ cherr <= "can't open file: " <= filename <= " for reading..." <= IO.nl(); me.exit();} // variable to read intostring str; // loop until endwhile( fio => str ){ chout <= str <= IO.newline();}
// default file
me.dir() + "read-str.txt" => string filename;
// look at command line
if( me.args() > 0 ) me.arg(0) => filename;
// instantiate
FileIO fio;
// open a file
fio.open( filename, FileIO.READ );
// ensure it's ok
if( !fio.good() )
{
cherr <= "can't open file: " <= filename <= " for reading..." <= IO.nl();
me.exit();
}
// variable to read into
string str;
// loop until end
while( fio => str )
{
chout <= str <= IO.newline();
}