Prev Next Title Contents

TEXT FILE INPUT / OUTPUT


Gifa has the capability of reading and writing on ASCII text files.

LOG_FILE CONNECT DISCONNECT

In permanence, all the input generated by the user, and the output generated by the program are journaled in a file called gifa.log. This file can be either kept or removed when exiting the program. At any time the user may redirect the journaling to another file with the command : CONNECT file_name. The program will then create a file called file_name where all the journaling will go. The command DISCONNECT will resume the journaling to the gifa.log default file, and close the previously CONNECTed file. If the command CONNECT is issued while a file is already CONNECTed, the former file will closed, and the new file will be opened.

OPEN CLOSE FPRINT <file_name eof(file_name)

It is also possible to read and write directly into text files. The command OPEN file_name, will open the file file_name for input or output. The command CLOSE will close the file. Ten different such files may be opened at once. An OPENed file may be written with the command FPRINT file_name output. A OPENed file may be read with the <file syntax (see below). When OPEN is issued on an already OPENed file, the file is rewound to the first line. The eof(file_name) function (see below) will have a value of 1 if the end of file was reached during the last <file_name operation and 0 otherwise.

Formatted output, the printf, fprintf, sprintf macros

There is no direct support for formatted output in Gifa, however, three macros have been written to implement this facility : printf, fprintf, and sprintf. They are called by giving first a format, then a list of parameters (finished with a *). fprintf has an additive parameter which is the name of the file (which must have been OPENed first). sprint puts the result into a static variables called $returned.

eg :

printf "Size of the data-set \t%d x %d\n" $si1_2d $si2_2d *

These macros are implemented by calling 'awk' (a UNIX facility) with the SH command. This implies that : i) they are a bit slow; ii) they may fail (SH fails when memory is low on the machine); iii) errors in formats will be detected by awk, not by Gifa (nawk has much better error messages that the old awk); iv) type man awk to get information on the available formats.


Prev Next Title Contents