User guide

open fp = mydata;
do until eof(fp);
print readr(fp,200);;
endo;
fp = close(fp);
end;
Theoutput ... resetcommandwillcreateanauxiliaryoutputfilecalledmyda-
ta.asctoreceivetheoutput.Thewindowisturnedofftospeeduptheprocess.The
GAUSSdatafilemydata.datisopenedforreadingand200rowsarereadperiter-
ationuntiltheendofthefileisreached.Thedatareadareprintedtotheauxiliaryoutput
mydata.asconly,becausethewindowisoff.
22.1.2 General File I/O
getfwillreadafileandreturnitinastringvariable.Anykindoffilecanbereadin
thiswayaslongasitwillfitintoasinglestringvariable.
Toreadfilessequentially,usefopentoopenthefileandusefgets,fputs,and
associatedfunctionstoreadandwritethefile.Thecurrentpositioninafilecanbedeter-
minedwithftell.ThefollowingexampleusesthesefunctionstocopyanASCIItext
file:
proc copy(src, dest);
local fin, fout, str;
fin = fopen(src, "rb");
if not fin;
retp(1);
endif;
fout = fopen(dest, "wb");
if not fin;
call close(fin);
retp(2);
22-6
GAUSSUser Guide