home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pds.zip / BOUNCE1.CMD next >
OS/2 REXX Batch file  |  1994-03-09  |  5KB  |  249 lines

  1. /*REXX*/
  2.  
  3.   signal on HALT    name HaltExit
  4.   /***
  5.   signal on ERROR   name ErrorExit
  6.   signal on FAILURE name FailureExit
  7.   signal on SYNTAX  name SyntaxExit
  8.   ***/
  9.  
  10. main:
  11. parse arg p1
  12.   fInit    ='N'
  13.   fDebug   = 'N'
  14.   fDispStax= 'N'
  15.   fDispHelp= 'N'
  16.  
  17.   CALL rParseParms p1
  18.  
  19.   if fDebug = 'Y' then
  20.    do
  21.     trace ?r
  22.    end
  23.  
  24.   if fDispStax = 'Y' then
  25.    do
  26.     CALL rDispSyntax 0, 0
  27.    end
  28.  
  29.   if fDispHelp = 'Y' then
  30.    do
  31.     CALL rDispSyntax 1, 0
  32.    end
  33.  
  34.   /* Actual routine */
  35.   rc   = rLoadFuncs('rxPDLoadFuncs', 'HSSPD', 'rxPDLoadFuncs')
  36.   if rc <> 0 then
  37.    do
  38.     Call rSiren 1, 1
  39.     say 'BOUNCE1 - Unable to initialize the "RXPD" subsystem'
  40.     exit 8
  41.    end
  42.  
  43.   sGlobal.iMaxR = 25
  44.   sGlobal.iMaxC = 80
  45.   sGlobal.fDebug=fDebug
  46.  
  47.   bid = rxPDInit('BOUNCE1','GREENHI','RED','REDHI',,25,80)
  48.   if bid = x2c(00000000) then
  49.    do
  50.     Call rSiren 2, 3
  51.     say 'BOUNCE1 - Error to initializing the "RXPD" subsystem'
  52.     exit 8
  53.    end
  54.  
  55.   fInit    ='Y'
  56.  
  57.   Call rxPDZVarDefine
  58.   sRow    = ''
  59.  
  60.   akey = rxPDDisplay(bid,'PANEL000')
  61.   do while 0 = rDoBOUNCE(bid)
  62.   end /* do while 0 = rDoBOUNCE() */
  63.  
  64.   rc = rxPDTerm(bid)
  65.  
  66.   exit 0
  67.  
  68. /**********************************************************************\
  69.  rDoBOUNCE:
  70.   This routine displays a dialog panel that bounces a ball
  71. \**********************************************************************/
  72. rDoBOUNCE:
  73. parse arg bid
  74.  
  75.   r = 1
  76.   c = 1
  77.   rd = +1
  78.   cd = +1
  79.   do FOREVER
  80.  
  81.    if c > 1 then
  82.     do
  83.      sRow = LEFT(' ',c-1,' ')'DB'x
  84.     end
  85.    else
  86.     do
  87.      sRow = 'DB'x
  88.     end
  89.  
  90.    akey = rxPDDisplay(bid, 'PANEL'RIGHT(r,3,'0'))
  91.  
  92.    r = r + rd
  93.    if r < 1 then
  94.     do
  95.      Call BEEP 1024, 25
  96.      r = 2
  97.      rd = +1
  98.     end
  99.    else
  100.    if r > sGlobal.iMaxR then
  101.     do
  102.      Call BEEP 1024, 25
  103.      r = sGlobal.iMaxR - 1
  104.      rd = -1
  105.     end
  106.  
  107.    c = c + cd
  108.    if c < 1 then
  109.     do
  110.      Call BEEP 1024, 25
  111.      c = 2
  112.      cd = +1
  113.     end
  114.    else
  115.    if c > sGlobal.iMaxC then
  116.     do
  117.      Call BEEP 1024, 25
  118.      c = sGlobal.iMaxC - 1
  119.      cd = -1
  120.     end
  121.  
  122.   end /*do FOREVER */
  123.  
  124.   return 0;
  125.  
  126. HaltExit:
  127.   if fInit = 'Y' then
  128.    do
  129.     rc = rxPDTerm(bid)
  130.    end
  131.   Call BEEP 882, 40
  132.   Call BEEP 882, 40
  133.   say ''
  134.   say 'BOUNCE1 processing halted by request;'
  135.   exit 0
  136.  
  137. ErrorExit:
  138.   Call BEEP 882, 40
  139.   Call BEEP 882, 40
  140.   say 'BOUNCE1 processing failed due to unknown error;'
  141.   exit 24
  142.  
  143. FailureExit:
  144.   Call BEEP 882, 40
  145.   Call BEEP 882, 40
  146.   say 'BOUNCE1 processing failed due to unknown failure;'
  147.   exit 32
  148.  
  149. SyntaxExit:
  150.   Call BEEP 882, 40
  151.   Call BEEP 882, 40
  152.   say 'BOUNCE1 processing failed due to syntax error;'
  153.   exit 64
  154.  
  155. rParseParms:
  156. parse arg p1
  157.  
  158.   do Forever
  159.    w1 = word(p1,1)
  160.    parse var w1 with "/" f1 ":" v1
  161.    select
  162.     when (w1 = '') then
  163.      do
  164.       return 0
  165.      end
  166.     when TRANSLATE(w1) = '/DEBUG' then
  167.      do
  168.       fDebug='Y'
  169.       p1 = SUBWORD(p1,2)
  170.      end
  171.     when TRANSLATE(f1) = 'D' then
  172.      do
  173.       fDebug = TRANSLATE(v1)
  174.       p1 = SUBWORD(p1,2)
  175.      end
  176.     when TRANSLATE(f1) = '?' then
  177.      do
  178.       fDispStax='Y'
  179.       fDispHelp='N'
  180.       p1 = SUBWORD(p1,2)
  181.      end
  182.     when TRANSLATE(f1) = 'H' then
  183.      do
  184.       fDispStax='N'
  185.       fDispHelp='Y'
  186.       p1 = SUBWORD(p1,2)
  187.      end
  188.     otherwise
  189.      do
  190.       Call rSiren 8, 1
  191.       say 'BOUNCE1 - Invalid parm specified; Parm "'w1'" unknown;'
  192.       CALL rDispSyntax 0 8
  193.      end
  194.    end
  195.   end
  196.  
  197.   return 0
  198.  
  199. rDispSyntax: Procedure
  200. parse upper arg iHelp iExit
  201.  
  202.   say ' Syntax  : BOUNCE1 {<options>} '
  203.   say '           BOUNCE1 {/?|/h}'
  204.   if iHelp > 0 then
  205.    do
  206.     CALL rDispHelp
  207.    end
  208.  
  209.   exit iExit
  210.  
  211. rDispHelp: Procedure
  212.  
  213.   say ' Options : /?         - Display command syntax.'
  214.   say '           /h         - Display this help info.'
  215.   say ' Examples:'
  216.   say '    BOUNCE1 /h'
  217.   say ' '
  218.   say '    BOUNCE1'
  219.  
  220.   return ''
  221.  
  222. /* rSiren: does the siren bit by running the scale based upon a       */
  223. /*    frequency specified by the caller.                              */
  224. rSiren: Procedure
  225.    Parse Arg freq, cycle
  226.    note.1 = 262 * freq /* middle C */
  227.    note.2 = 294 * freq /* D */
  228.    note.3 = 330 * freq /* E */
  229.    note.4 = 349 * freq /* F */
  230.    note.5 = 392 * freq /* G */
  231.    note.6 = 440 * freq /* A */
  232.    note.7 = 494 * freq /* B */
  233.    note.8 = 524 * freq /* C */
  234.    do j = 1 to cycle
  235.     call beep note.8,250 /* hold each note for a 1/4 second */
  236.     call beep note.1,250 /* hold each note for a 1/4 second */
  237.    end j
  238.    Return
  239.  
  240. rLoadFuncs:
  241. parse arg sREP, sDll, sRtn
  242.   rxrc = RxFuncAdd(sREP, sDll, sRtn)
  243.   signal on syntax name xLoadFuncs
  244.   interpret 'Call 'sRtn
  245.   return 0
  246.  
  247. xLoadFuncs:
  248.   return 127
  249.