home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Educate / Educate.zip / letters1.zip / LETTERS.CMD next >
OS/2 REXX Batch file  |  1997-05-02  |  4KB  |  173 lines

  1. /* Author - J. Pedone */
  2. /* Questions or comments ? */
  3. /* E-Mail me at jpedone@flash.net */
  4.  
  5. /* Legal Stuff: */
  6. /* This program is provided as is for free and I make no warranties */
  7. /* So have a great day ! */
  8.  
  9. /* Start things rolling */
  10. /* Load REXX functions */
  11.     call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  12.     call SysLoadFuncs
  13. /* Load MCI REXX support */
  14.     Call RXFUNCADD "mciRxInit","MCIAPI","mciRxInit"
  15.     Call mciRxInit
  16. /* Load RXU functions */
  17.     call rxfuncadd 'rxuinit','rxu','rxuinit'
  18.     call rxuinit
  19. /* Cleans things up at program termination */
  20.     signal on halt
  21. /* Initialize a counter */
  22.     times = 0
  23.  
  24. pick_a_letter:
  25. /* set some program variables and run some checks */
  26.     pid = 'VB.EXE'
  27.  
  28. /* Change this line if VB is located elsewhere */
  29.     full_name = 'C:\MMOS2\VB.EXE'    
  30.  
  31.     type = 'P'
  32.     procname = pid
  33.     letter = RANDOM(1,26) 
  34.     picture = RANDOM(1,26) 
  35.  
  36. /* Make sure at least a few of the letters and sounds match */
  37.     IF picture = letter THEN times = 0
  38.     ELSE times = times + 1
  39.     IF times > 4 THEN
  40.         DO
  41.             times = 0
  42.             letter = picture
  43.         END
  44. /* This section gets rid of the problem letters like K, C, Z & X */
  45. /* Set picture to C if sound is C AND picture is K */
  46.     IF letter = 3 THEN
  47.         DO
  48.         IF picture = 11 THEN
  49.             DO
  50.             picture = 3
  51.             END
  52.         END
  53.  
  54. /* Set picture to K if sound is K AND picture is C */
  55. IF letter = 11 THEN
  56.         DO
  57.         IF picture = 3 THEN
  58.             DO
  59.             picture = 11
  60.             END
  61.         END
  62.  
  63. /* Set picture to Z if sound is Z AND picture is X */
  64.     IF letter = 26 THEN
  65.         DO
  66.         IF picture = 24 THEN
  67.             DO
  68.             picture = 26
  69.             END
  70.         END
  71.  
  72. /* Set picture to K if sound is K AND picture is C */
  73.     IF letter = 24 THEN
  74.         DO
  75.         IF picture = 26 THEN
  76.             DO
  77.             picture = 24
  78.             END
  79.         END
  80.  
  81. /* change these two lines as appropriate if you use other than TIFF or WAVE files */
  82. picfile = '.\pic\'picture'.tif'
  83. wavfile = '.\wav\'letter'.wav'
  84.  
  85. display_picture:
  86. /* Kill VB if it's running */
  87.     rc = rxqprocstatus('q.','l')
  88.     find_it=q.0P.0
  89.         do n=1 to find_it
  90.             found = q.0p.n.6
  91.         if found = full_name THEN CALL kill_vb
  92.         end
  93. /* Start vb and wait for the desktop to release the sound card */
  94.     view = 'START VB 'picfile
  95.     view
  96.     CALL SysSleep(10)
  97.  
  98. play_sound:
  99. /* play the sound files */
  100.     MacRC = SendString(open Waveaudio wait)
  101.     MacRC = Sendstring(load Waveaudio wavfile wait)
  102.     MacRC = Sendstring(play Waveaudio wait)
  103.     MacRC = SendString(close Waveaudio wait)
  104.  
  105. interact:
  106. /* Put up some message boxes to control program flow */
  107.     answer = RxMessageBox('Does the sound match ?', '(Cancel = quit)', YESNOCANCEL, QUESTION)
  108.     IF answer = 2 THEN SIGNAL halt
  109.     IF answer = 6 THEN
  110.         DO
  111.         IF picture = letter THEN
  112.             DO
  113.                 IF RxMessageBox('You are right !! Try another ?', Correct, YESNO, QUESTION) = 6 THEN SIGNAL pick_a_letter
  114.                     ELSE
  115.                 SIGNAL halt
  116.             END
  117.         ELSE
  118.             DO
  119.                 IF RxMessageBox('You are wrong !! Try Again ?', Wrong, YESNO, QUESTION) = 6 THEN SIGNAL play_sound
  120.                     ELSE
  121.                 SIGNAL pick_a_letter
  122.             END
  123.         END
  124.     IF answer = 7 THEN
  125.             DO
  126.             IF picture <> letter THEN
  127.                 DO
  128.                     IF RxMessageBox('You are right !!  Try another ?', Correct, YESNO, QUESTION) = 6 THEN SIGNAL pick_a_letter
  129.                         ELSE
  130.                     SIGNAL halt
  131.                 END
  132.             ELSE
  133.                 DO
  134.                     IF RxMessageBox('You are wrong !! Try again ?', Wrong, YESNO, QUESTION) = 6 THEN SIGNAL interact
  135.                         ELSE
  136.                     SIGNAL pick_a_letter
  137.                 END
  138.             END
  139.     SIGNAL halt
  140.  
  141. halt:
  142. /* Halt program and release MCI functions */
  143.     full_name = 'C:\MMOS2\VB.EXE'    
  144.     type = 'P'
  145.     procname = pid
  146.     CALL kill_vb
  147.     call mciRxExit
  148.     exit
  149.  
  150. kill_vb:
  151. /* kill the picture viewer */
  152.     dosrc = rxqprocstatus('s.')
  153.     do i=1 to s.0p.0
  154.         do
  155.         if abbrev(translate(filespec('n',s.0p.i.6)),translate(procname)) then 
  156.           do
  157.           procname = s.0p.i.6
  158.           xpid = strip(s.0p.i.1,'l','0')
  159.           pid = x2d(xpid)
  160.           dosrc = rxkillprocess(pid,type)
  161.           RETURN
  162.           end
  163.         end
  164.     end
  165.     RETURN
  166.  
  167. SendString:
  168. /* Build MCI command */
  169.     arg CmndTxt
  170.     MacRC = mciRxSendString(CmndTxt, 'RetSt', '0', '0')
  171.     return MacRC
  172.  
  173.