Debian Codegraph @

src/test/03-Modules/05-read-str.ck

raw
1 // default file
2 me.dir() + "05-read-str-data.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 => str )
25 {
26 cherr <= str <= IO.newline();
27 }