Debian Codegraph @

src/test/03-Modules/02-read-float.ck

raw
1 //---------------------------------------------------------------------
2 // name: read-float.ck
3 // desc: basic example of reading floats using FileIO
4 //---------------------------------------------------------------------
5
6 // default file
7 me.dir() + "02-read-float-data.txt" => string filename;
8
9 // look at command line
10 if( me.args() > 0 ) me.arg(0) => filename;
11
12 // instantiate
13 FileIO fio;
14
15 // open a file
16 fio.open( filename, FileIO.READ );
17
18 // ensure it's ok
19 if( !fio.good() )
20 {
21 cherr <= "can't open file: " <= filename <= " for reading..."
22 <= IO.newline();
23 me.exit();
24 }
25
26 // variable to read into
27 float val;
28
29 // loop until end
30 while( fio => val )
31 {
32 cherr <= val <= IO.newline();
33 }