Introductory example
The standard Mosel syntax for reading and writing data uses initializations blocks to access external files, such as
declarations A: array(set of integer) of real ! Array of unknown size (=dynamic) B: array(1..7) of string ! Array of known size (=static) end-declarations initializations from "mydata.dat" A B as "MyB" end-initializations
where the datafile mydata.dat may have the following contents:
A: [(3) 2 (1) 4.2 (6) 9 (10) 7.5 (-1) 3] MyB: ["Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"]
To obtain access to file types other than text files in Mosel format we merely need to modify the filename string, prefixing the name of the data source by the I/O driver we want to use followed by a colon. For instance, to read a text file in comma separated format we may use the driver prefix "mmetc.diskdata:". I/O drivers may be seen as filters that decode data from some other format, transforming it into the format used by Mosel—or the other way round. For further detail on the concept of I/O drivers, the reader is referred to the Xpress Whitepaper Generalized file handling in Mosel.