{$m $ff02, 0, 0}

program LINK (input, output);

uses
  crt, dos, CAL;

var
  Tekst : string;

procedure RunThis (Tekst : string);
  begin
    swapvectors;
    exec (getenv ('COMSPEC'), '/C '+Tekst);
    swapvectors;
  end;

begin
  nosound;
  writeln;
  textcolor (lightmagenta);
  write ('U');
  textcolor (lightgray);
  write ('ltra ');
  textcolor (cyan);
  write ('B');
  textcolor (brown);
  write ('asic ');
  textcolor (yellow);
  write ('linker to use ');
  textcolor (white);
  write ('PRECOMPI.EXE');
  textcolor (yellow);
  writeln (' output .PAS file to make an executable.');
  writeln;
  if paramcount < 1 then begin
    writeln ('Usage: ', paramstr (0), ' <Compiled_with_PRECOMPI[.PAS]> .... .. ... ..');
    writeln;
    halt (0);
  end;
  Tekst:= paramstr (1);
  Tekst:= UpString (Tekst);
  if pos ('.', Tekst) = 0 then
    Tekst:= Tekst + '.PAS';
  RunThis ('tpc.exe /b '+Tekst);
  delete (Tekst, pos('.PAS', Tekst), 255);
  Tekst:= Tekst + '.EXE';
  RunThis ('tppatch.exe '+Tekst);
  halt(0);
  exit;
  exit { 2 kiekens op ne veloo... ..}
end.