Not a whole lot to report , but I did write one utility program this weekend in Turbo Pascal for my CP/M system.

This one was a simple clone of the UNIX more(1) program. Since CP/M only comes with the built-in "type", similar to UNIX's cat(1), I thought it would be both useful and educational to rewrite more in pascal. In the end, I think I accomplished both goals.

more is useful for looking through text files like program source listings, and programming it got me back into a few things in Turbo, and pascal in general:

1. I had to relearn the Turbo (I'm using TP 3.0) system - how to edit, compile, etc.
2. I relearned some simple file and console I/O - opening, closing, resetting, and reading from files, and writing to the console.
3. I learned how to process command line arguments in TP 3.0. This was necessary since there is no redirection or piping in CP/M.

In the end, the program was short and simple. I include it below in case anyone is interested.

{*

  • more: display a text file page by page
  • Tom Manos
  • 2/21/2010
  • Written for CP/M Turbo Pascal 3.0
  • }

program more;

var
i : integer;
linecount : integer;
line : string[255];
pagelen : integer;
myfile : Text;

begin
pagelen := 24;
for i := 1 to ParamCount do
begin
Assign(myfile,ParamSTR(i));
Reset(myfile);
while not Eof(myfile) do
begin
for linecount := 1 to pagelen do
begin
ReadLn(myfile,line);
WriteLn(line);
end;

write('Press a key...');
while not KeyPressed do
;

writeln();
end;
Close(myfile);
end;
end.

Not sure why the indentation didn't come across when I pasted the source code in here, but no time to fix it now :)