program cmdline;
{ tests the command line interface -- 09.05.1987 A.Herrmann }

const
    BLANK = #$20;
    INDEFAULT = 'TRM';
    OUTDEFAULT = 'TRM';
type
    string14 = string[14];
    string127 = string[127];
var
    cmdline: string[127] absolute $80;
    cmdlength: integer;
    inname,outname: string[14];
    i: integer;

procedure getword(var str:string127; first:integer; var word:string14; var behind:integer);
var i,j,strlen: integer;
begin
i:=first;
strlen:=length(str);
while (str[i] = BLANK) and (i <= strlen) do i:=i+1;
{writeln('Begin of parameter at ',i); }
if (i>strlen) then
    begin
    word:='';
    behind:=first;
    end
else
    begin
    j:=pos(BLANK,copy(str,i,strlen-i+1));
{    writeln('End of parameter at ',j); }
    if (j=0) then j:=strlen-i+1;
{     writeln('Length of parameter is ',j); }
    word:=copy(str,i,j);
    behind:=i+j;
    end;
end;

begin
{write('Enter command line: ');
readln(cmdline); }
cmdlength:=length(cmdline);
writeln(cmdline);
writeln('cmdlength=',cmdlength);
getword(cmdline,2,inname,i);
getword(cmdline,i,outname,i);
if (length(inname) = 0) then inname:=INDEFAULT;
if (length(outname) = 0) then outname:=OUTDEFAULT;
{
for i:=1 to length(inname) do inname[i]:=UpCase(inname[i]);
for i:=1 to length(outname) do outname[i]:=UpCase(outname[i]);
}
writeln(' - Input file is ',inname,' - Output file is ',outname);
end.
