home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 480.lha / BuildScreen_v2.0 / numbers.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1991-02-06  |  5.6 KB  |  165 lines

  1. /* */
  2. options results
  3. here  = pragma('D','ram:')
  4. there = pragma('D',here)
  5. address command 'cd '|| here||'0a'x||'stack 20000'||'0a'x|| 'c:run >nil: tbuildscreen numbers.dat nil:'
  6.  
  7. address command 'waitforport xxxport'||'0a'x|| 'waitforport xxxport'
  8. address command 'waitforport xxxport'||'0a'x|| 'waitforport xxxport'
  9. call problem
  10.  
  11. got = 0
  12. do forever
  13.         address 'xxxport' 'RWAIT'             /* wait for user to do something */
  14.         a = RESULT
  15.         parse var a action p2 p3 p4 p5 p6 .   /* parse response from buildscreen */
  16.  
  17.         /* say 'here is the result "'|| a ||'"'  */
  18.  
  19.         if action = "" then do                /* this is a menu null (rmb down no select ) */
  20.                 address 'xxxport' 'fillbox wname8 199 190 10 7 2 3'
  21.                 say 'menu null'
  22.         end
  23.         if action = "C" then do               /* close box hit */
  24.                 say 'window closed'
  25.                 leave
  26.         end
  27.  
  28.         if action = "K" then do               /* raw keystroke */
  29.  
  30.                 qual = p4
  31.                 code = p5
  32.                 xxx = "code = "||"c2d('"||p5||"'X)";interpret xxx  /* convert hex to number */
  33.                 xxx = "qual = "||"c2d('"||p4||"'X)";interpret xxx  /* convert hex to number */
  34.                 if code < 128 then do
  35.                    call liveone
  36.                 end
  37.         end
  38.         if action = "P" then do               /* pointer button up or down */
  39.                 x = p2
  40.                 y = p3
  41.                 xxx = "code = "||"c2d('"||p5||"'X)";interpret xxx  /* convert hex to number */
  42.  
  43.                 if code < 128 then do
  44.                         say 'point down at ' x ' ' y
  45.                 end
  46.         end
  47. end
  48. /*
  49.         if action = "G" then do               /* gadget hit */
  50.  
  51.         end
  52.         if action = "M" then do               /* menu op */
  53.  
  54.                 say 'Menu checked=' p2 ' menu# ' p3  ' item ' p4 ' sub item ' p5
  55.         end
  56.  
  57. */
  58.  
  59. exit
  60.  
  61.  
  62.  
  63. problem:
  64.         a1 = random(0,9,time(seconds))
  65.         a2 = random(1,4)
  66.         b1 = random(0,9)
  67.         b2 = random(1,4)
  68.         ans = a2*10 + a1 + b2*10 + b1
  69.  
  70.         tens = 0
  71.         ones = 0
  72.         
  73.  
  74.        address 'xxxport' 'drawimage wname p'||a2|| ' 110 50'
  75.        address 'xxxport' 'drawimage wname p'||a1|| ' 160 50'
  76.        address 'xxxport' 'drawimage wname p'||b2|| ' 110 120'
  77.        address 'xxxport' 'drawimage wname p'||b1|| ' 160 120'
  78.        address 'xxxport' 'drawimage wname plus        60 127'
  79.        address 'xxxport' 'drawimage wname min         101 180'
  80.        address 'xxxport' 'blit      wname 114 200 wname 132 200 25 10 192'
  81.        address 'xxxport' 'blit      wname 114 200 wname 151 200 25 10 192'
  82.        address 'xxxport' 'blit      wname 114 200 wname 170 200 25 10 192'
  83.  
  84. return
  85.  
  86. liveone:
  87.  
  88.                    /* say 'down keystroke = (' p4 p5 ') = (' qual code ')' */
  89.                    if code = 10 then do
  90.                       code = 0
  91.                    end
  92.                    if code = 65 then do   /* backspace */
  93.                       call backspace
  94.                    end
  95.                    if (code >= 0)  & (code <= 9) then do
  96.                       if got = 0 then do
  97.                          xx = 160 ; yy = 210    /* coords of first number */
  98.                          got = 1
  99.                          ones = code
  100.                          end
  101.                       else do
  102.                          xx = 110  ; yy = 210  /* second number */
  103.                          got = 2
  104.                          tens = code
  105.                       end
  106.  
  107.                       address 'xxxport' 'drawimage wname p'||code   xx yy
  108.                    end
  109.                    if code = 68 then do
  110.                       call cr
  111.                    end
  112. return
  113.  
  114. backspace:
  115.                       if got = 1 then do
  116.                           got = 0         /* erase first number on right */
  117.                           address 'xxxport' 'blit      wname 240 220 wname 152 214 50 70 192'
  118.  
  119.                           end
  120.                       else if got = 2 then do
  121.                           got = 1         /* erase second number on right */
  122.                           address 'xxxport' 'blit      wname 240 220 wname 110 214 50 70 192'
  123.  
  124.                       end
  125.  
  126. return
  127.  
  128. cr:
  129.                       product = tens*10+ones
  130.                       if product = ans then do
  131.                          /* address 'xxxport' 'fillbox wname 0 0 100 100 0 0' */
  132.                          address 'xxxport' 'drawimage wname right 0 0'
  133.  
  134.                          call delay(100)
  135.                          address 'xxxport' 'fillbox wname 0 0  250 280 0 0'
  136.                          
  137.                          call rollem
  138.                          
  139.                          address 'xxxport' 'fillbox wname 0 0  250 280 0 0'
  140.  
  141.                          got = 0
  142.                          call problem
  143.                          end
  144.                       else do
  145.                          address 'xxxport' 'fillbox wname 0 0 100 100 0 0'
  146.                          address 'xxxport' 'drawimage wname try 0 0'
  147.                       end
  148.  
  149. return
  150.  
  151. rollem:
  152.                       k = -110
  153.                       do i = 9 to 0 by -1
  154.                          address 'xxxport' 'drawimage wname p'||i 110 210+k
  155.                          k = k + 11
  156.                          l = -100
  157.                          do j = 9 to 0  by -1
  158.                                    address 'xxxport' 'drawimage wname p'||j 160 210+l
  159.                                    l = l + 10
  160.                          end
  161.                       end
  162.                       address 'xxxport' 'drawimage wname min   160 210'
  163.                       address 'xxxport' 'drawimage wname min   110 210'
  164.                       address 'xxxport' 'fillbox wname 78 222  180 80 0 0'
  165.