{$M 16384,0,50000} {NOTE: do NOT use maximum heap!}

uses
  Crt, Dos;

type
  str66 = string[66];

var
  acd_buffer_name: str66;
  x: longint;
  string_address: string[20];

procedure call_acd(s1, s2: str66);
begin

  acd_buffer_name := 'ACD '+s2;
  x := longint(addr(acd_buffer_name)); str(x, string_address);

  exec(fsearch('acd.exe','.;'+getenv('PATH')),'/x'+string_address+' *'+s1);

  if (doserror = 0) and (dosexitcode = 0) then
    writeln('CHOSEN path = ',acd_buffer_name)
  else
  if dosexitcode <> 0 then
    writeln('Dos exit code: ',dosexitcode)
  else
    writeln('FAILED');
  writeln;
end;

begin
  ClrScr;
  Writeln('We would like to see ALL directories (*), and also show these directories ');
  Writeln('at the top of our screen (/t), with only 10 directories at a time (/w10)');
  writeln('ESC will cause a "FAILED", selection will return a PATH');
  writeln;
  call_acd('*','/w10/t');

  writeln;
  writeln('Now we would like to see all directories at the bottom of our screen (/b), ');
  writeln('in reverse colors (/reverse), and with only 6 directories at a time (/w6)');
  writeln;
  call_acd('* /reverse ','/w06/b');

  writeln;
  writeln('Now we would like to see only those dirs starting with an "A" (a*),');
  writeln('at the bottom of our screen (/b), in the non-graphical presentation (/g0)');
  writeln('in normal colors, and with only 2 directories at a time (/w2)');
  writeln;
  call_acd('a* /g0','/w02/b');

  writeln;
  writeln('Now we would like to see in the non-graphical presentation (/g0) ');
  writeln('all directories in the center of the screen (/c), in reverse colors (/reverse)');
  writeln('and with only 4 directories at a time (/w4)');
  writeln;
  call_acd('* /reverse /g0','/w04/c');
  writeln;

end.
