Lower Case Program |
Top Previous Next |
\This program copies a file, shifting all characters to lowercase.
code Reserve=3, ChIn=7, ChOut=8, CRLF=9, Text=12, OpenI=13, OpenO=14, Close=15, FSet=24, FOpen=29, FClose=32 CommandLine=90;
int HandIn, HandOut, \File handles I; \Scratch
char InFilename(256),OutFilename(256);
char C;
procedure HandleError(Msg); char Msg; begin Text(0,Msg); CRLF(0); C:=Chin(1); exit; end;
begin \Get command line arguments if not CommandLine(1,InFilename,256) then HandleError("No Input File Specified"); if not CommandLine(2,OutFilename,256) then HandleError("No Output File Specified");
\Display the filenames Text(0,"Input: "); Text(0,InFilename); CRLF(0); Text(0,"Output: "); Text(0,OutFilename); CRLF(0);
HandIn:= FOpen(InFilename, 0); \Open first file name for input FSet(HandIn, ^I); OpenI(3);
HandOut:= FOpen(OutFilename, 1); \Open second file name for output FSet(HandOut, ^O); OpenO(3);
repeat I:= ChIn(3); \Copy and shift to lowercase if I>=^A & I<=^Z then I:= I !$20; ChOut(3, I); until I = \EOF\ $1A;
Close(3); FClose(HandIn); FClose(HandOut); Text(0,"File Converted"); C:=Chin(1); end; |