home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
TPKERMIT
/
LOCAL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-03-25
|
5KB
|
144 lines
(* +FILE+ LOCAL.PASMSCPM *)
(* ----------------------------------------------------------------- *)
(* DisplayDir - Displays the directory for the mask given in the *)
(* input parameter string. *)
(* ----------------------------------------------------------------- *)
Procedure DisplayDir (Myfiles : Comstring) ;
var
filename : comstring ;
column,row : integer ;
Begin (* DisplayDir Procedure *)
if (length(myfiles)<1) or (Myfiles[length(myfiles)] in ['\','/',':'])
then myfiles := myfiles + '*.*';
Clrscr;
If firstfile(myfiles,filename) then
Begin (* found files *)
writeln(' directory ',myfiles);
write(filename);
column := 21 ; row := 2;
while nextfile(myfiles,filename) do
begin (* list rest of files *)
gotoxy(column,row);
write (filename);
column := column + 20 ;
if column > 61 then
begin row := row + 1 ; column := 1 ; end ;
end ; (* list rest of files *)
End (* found files *)
else
writeln(' no file found ');
writeln(' ');
DisplayDiskStatus ;
End ; (* DisplayDir Procedure *)
(* ----------------------------------------------------------------- *)
(* EraseFiles - Erases a file or files from the disk. *)
(* *)
(* ----------------------------------------------------------------- *)
Procedure EraseFiles (Myfiles : Comstring) ;
var
tempname : comstring ;
tempfile : text ;
column,row : integer ;
Begin (* EraseFile Procedure *)
While length(myfiles)<1 do
Begin (* get file name *)
write(' enter name of file to be erased > ');
readln(myfiles);
End ;
If firstfile(myfiles,tempname) then
Begin (* found files *)
Clrscr;
writeln(' Erasing file(s) ',myfiles);
assign(tempfile,prefixof(myfiles)+tempname);
erase(tempfile);
write(tempname);
column := 21 ; row := 2;
while nextfile(myfiles,tempname) do
begin (* list rest of files *)
gotoxy(column,row);
assign(tempfile,prefixof(myfiles)+tempname);
erase(tempfile);
write (tempname);
column := column + 20 ;
if column > 61 then
begin row := row + 1 ; column := 1 ; end ;
end ; (* list rest of files *)
writeln(' ');
writeln('The above file(s) have been erased. ');
End (* found files *)
else
writeln(' no file found ');
End; (* EraseFile *)
(* ----------------------------------------------------------------- *)
(* RenameFile - Remame a file. *)
(* *)
(* ----------------------------------------------------------------- *)
Procedure RenameFile (Var Instring : Comstring) ;
var
oldnames,oldname,newname : comstring ;
tempfile : text ;
label exit ;
Begin (* RenameFile Procedure *)
If length(Instring)<1 then
Begin (* get file name *)
write(' Enter old file name > ');
readln(Instring);
End ; (* get file name *)
If length(Instring)<1 then goto exit ;
oldnames := uppercase(GetToken(instring));
newname := uppercase(GetToken(instring));
If length(newname)<1 then
Begin (* get new file name *)
write(' Enter new file name > ');
readln(Instring);
newname := uppercase(GetToken(instring));
End ; (* get new file name *)
If firstfile(oldnames,oldname) then
Begin (* found File *)
assign(tempfile,prefixof(oldnames)+oldname);
Rename(tempfile,newname);
writeln(' ');
writeln('File ',oldname, ' renamed to ',newname);
End (* found File *)
else
writeln(' No file - ',oldname);
exit:
End; (* RenameFile *)
(* ----------------------------------------------------------------- *)
(* DisplayFile - display a file. *)
(* *)
(* ----------------------------------------------------------------- *)
Procedure DisplayFile (Myfile : Comstring) ;
var
oldname,newname : comstring ;
tempfile : text ;
achar : char ;
label exit ;
Begin (* DisplayFile Procedure *)
If length(Myfile)<1 then
Begin (* get file name *)
write(' Enter file name > ');
readln(Myfile);
End ; (* get file name *)
If length(Myfile)<1 then goto exit ;
Assign(tempfile,myfile);
{ $I- } Reset(tempfile); { $I+ }
If IOResult = 0 then
Begin (* found File *)
Clrscr ;
While not eof(tempfile) do
begin (* Display file *)
Read(tempfile,achar);
Write(achar);
end; (* Display file *)
writeln(' ');
End (* found File *)
else
writeln(' No file - ',Myfile);
exit:
End; (* DisplayFile *)