{  This pascal procedure is for work with Song Editor 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], [SongName]);
  For example: 
         Play('music.dat','Glory');
}
procedure Play (FileName, SongName : 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 = SongName + ' ')
           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(SongName,' song is not found!');
end;

