Program CDROMCOM;
Uses CDROM;

Var B : Boolean;

Procedure Help;
Begin
  Writeln ('Usage CDROMCOM <command> where command is');
  Writeln ('                   p         for play');
  Writeln ('                   s         for stop');
  Writeln ('                   o         for open tray');
  Writeln ('                   c         for close tray');
  Writeln ('                   i         for time/track info');
  Writeln ('If you encounter any errors please mail me at');
  Writeln ('   c.w.g.m.enders@kub.nl');
End;

Procedure CDopen;
Begin
  Writeln('Opening CD player...');
  B:= CDEject;
End;

Procedure CDclose;
Begin
  Writeln('Closing CD player...');
  B:= CDCloseTray;
End;

Procedure StopCD;
Begin
  Writeln('CD stopped.');
  B:= CDStop;
End;


Procedure CDshowinfo;
Var Posinf : CDPosType;
    Temp : string;
Begin
  B:= cdgetpos(posinf);
  str(posinf.sec, temp);
  if posinf.sec < 10 then temp := '0' + temp;
  Writeln('Track : ',Posinf.Track:2,' - Time : ',posinf.min:2,':',temp);
  str(posinf.dsec, temp);
  if posinf.dsec < 10 then temp := '0' + temp;
  Writeln('Played total time : ',posinf.dmin:2,':',temp);
end;

Procedure CDplay;
var Len : longint;
    inf : CDInfoRecord;
    Posinf : CDPosType;
    T : byte;
Begin
  Writeln('Playing CD ...');
  T:= 1;
  B:= CDPlayAudio(T,$FFFFFFFF);
  cdshowinfo;
End;

Var Control : string;
Begin
  Writeln('CD-ROM commands --- version 1.0 --- FREEWARE by C.E. 1995');
  Control := Paramstr(1);
  If UPCASE (Control[1]) = 'O' then CDopen
  Else if UPCASE (Control[1]) = 'C' then CDclose
  Else if UPCASE (Control[1]) = 'S' then StopCD
  Else if UPCASE (Control[1]) = 'I' then CDShowInfo
  Else if UPCASE (Control[1]) = '?' then help
  Else cdplay;
End.