home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXXSAMP.ZIP / REXXBEEP.CMD next >
OS/2 REXX Batch file  |  1989-12-05  |  2KB  |  51 lines

  1. /*    */
  2. /*    Ring the bell. Every single programming text I have ever read
  3.       has a bell program so I've added one to the list.
  4.  
  5.       Usage: REXXBEEP music_file .
  6.       Where: music_file is the name of an OS/2 file that contains
  7.              frequency values. These values will be played.
  8.  
  9. The file is in the format
  10. 440 8
  11. 330 12
  12. .
  13. .
  14.  
  15. Where the first number is the frequency and the second number
  16. is the duration. Just stop when you run out of notes.
  17. */
  18.  
  19. NULL = ''                              /* Whats the null  */
  20. HELPME = '?'                           /* How do we get help */
  21.  
  22. arg music_file .                     /* the . is garbage collection
  23.                                         in case there are additional
  24.                                         arguments not needed       */
  25.  
  26. if music_file = NULL                  /* if it's null use mine */
  27. then file_in = 'REXXBEEP.MUS'         /* default file name */
  28. else file_in = arg(1)                 /* your file name   */
  29.                                       /* Someone could check
  30.                                          if the files exist. Nahhhh */
  31.  
  32. if arg(1) = HELPME                   /* show lines 6 to 17  */
  33.     then  do line = 5 while substr(sourceline(line),1,2) <> '*/'
  34.               say sourceline(line)
  35.               end
  36.  
  37. do xx = 1 while lines(file_in)   /* increment XX while reading lines */
  38.    beeptext=linein(file_in)      /* get a line */
  39.    push beeptext                 /* push the value on the stack */
  40.    pull beepfreq duration .      /* pull it back but in 2 parts    */    
  41.    beep(beepfreq, duration)      /*  beep   */
  42.    end
  43.  
  44. /* to avoid the firestorm caused by using this. I just wanted to
  45. demonstrate HOW to use the PUSH and PULL stuff. There are
  46. obviously ways ( PARSE) to get the answer in one line without
  47. using the stack.
  48. */
  49.  
  50. return
  51.