| 1 |
// default file |
| 2 |
me.sourceDir() + "jabberwocky.txt" => string filename; |
| 3 |
|
| 4 |
// look at command line |
| 5 |
if( me.args() > 0 ) me.arg(0) => filename; |
| 6 |
|
| 7 |
// instantiate |
| 8 |
FileIO fio; |
| 9 |
|
| 10 |
// open a file |
| 11 |
fio.open( filename, FileIO.READ ); |
| 12 |
|
| 13 |
// ensure it's ok |
| 14 |
if( !fio.good() ) |
| 15 |
{ |
| 16 |
cherr <= "can't open file: " <= filename <= " for reading..." <= IO.nl(); |
| 17 |
me.exit(); |
| 18 |
} |
| 19 |
|
| 20 |
// variable to read into |
| 21 |
string str; |
| 22 |
|
| 23 |
// loop until end |
| 24 |
while( fio.more() ) |
| 25 |
{ |
| 26 |
chout <= fio.readLine() <= IO.newline(); |
| 27 |
} |
| 28 |
|
| 29 |
<<< "\n------------", "" >>>; |
| 30 |
<<< "rewinding...", "" >>>; |
| 31 |
<<< "------------\n", "" >>>; |
| 32 |
fio.seek( 0 ); |
| 33 |
|
| 34 |
// loop until end |
| 35 |
while( fio.more() ) |
| 36 |
{ |
| 37 |
chout <= fio.readLine() <= IO.newline(); |
| 38 |
} |
| 39 |
|
| 40 |
|