{              PLAY procedure by A.A.Efros.
  This pascal procedure is for work with Melody Master Data files. 

  In Turbo Pascal one has to use Crt unit. (uses Crt;)  
  Crt unit is for functions: Sound, Delay and NoSound. 

  To call procedure Play one should:
         Play( [FileName], [MelodyName]);
  For example: 
         Play('music.dat','Glory');
}
procedure Play (FileName, MelodyName : string);
var
  q : integer;
  ch : char;
  st : string;
  Data : text;
begin
  assign(Data,FileName);
  reset(Data);
  st := '';
  while not EOF(Data) do
    begin
      st := '';
      repeat
        read(Data,ch);
        st := st + ch;
      until ch = ' ';
      if (st = MelodyName + ' ')
           then
             begin
               while not Eoln(Data) do
                 begin
                   read(Data,q);
                   Sound(q);
                   read(Data,q);
                   Delay(q);
                   NoSound;
                 end;
               Close(Data);
               Exit;
             end;
      readln(Data);
    end;
  Close(Data);
  Writeln(MelodyName,' Melody is not found!');
end;

