home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdlg11.zip / keys.cmd < prev    next >
OS/2 REXX Batch file  |  1995-03-02  |  7KB  |  224 lines

  1. /* An example of a window with the KEYS Flag set. We simply print out each
  2.  key that the user presses */
  3.  
  4. /* Trap ERROR and FAILURE */
  5. SIGNAL ON ERROR
  6. SIGNAL ON FAILURE
  7.  
  8.  
  9. /* ====================== 'Main Window' ======================= */
  10. /* First Group is TEXT */
  11. RXTYPE.1 = 'TEXT'
  12.  
  13. /* Default */
  14. RXFLAGS.1 = ' '
  15.  
  16. /* Text lines */
  17. RXLABEL.1 = "Press a key on the keyboard:"
  18.  
  19. /* TotalPhrases, PhrasesPerLine, WidthOfPhrase, BetweenPhrases */
  20. RXINFO.1 = '1 1 0 0'
  21.  
  22. /* Position */
  23. RXX.1 = 10
  24. RXY.1 = 30
  25.  
  26. /* Use another TEXT Group to display the key */
  27. RXTYPE.2 = 'TEXT'
  28.  
  29. /* Default */
  30. RXFLAGS.2 = ' '
  31.  
  32. /* Text lines */
  33. RXLABEL.2 = ' '
  34.  
  35. /* TotalPhrases, PhrasesPerLine, WidthOfPhrase, BetweenPhrases. Note that
  36.  we deliberately set WidthOfPhrase non-0 to allow enough width to accomodate
  37.  a range of text */
  38. RXINFO.2 = '1 1 200 0'
  39.  
  40. /* Position */
  41. RXX.2 = 10
  42. RXY.2 = 10
  43.  
  44. /* Default size and position (also gives us sizing and max button) */
  45. RXWINMAIN = ' '
  46. RXDLG 2 '"Main Window"' 'RXWINMAIN' 'NOCLOSE|KEYS'
  47.  
  48. more:
  49.    /* Do user interaction. We go to sleep while user manipulates the window
  50.       ounts down, until such time as the
  51.       user presses ESC or ENTER if the window's RESULT Flag is set, or tries
  52.       to close a dialog using its CLOSE ICON, or uses a RESULT Group, or
  53.       uses some Group with its END Flag set, or presses a key if the window's
  54.       KEYS Flag is set, or the timer times out */
  55.    RXDLG
  56.  
  57.    /* RXWIND now specifies which window woke us up. The window is still
  58.       there because we specified NOCLOSE. Even if we hadn't specified that,
  59.      the window would still be there if what caused RXDLG to return was a user
  60.      pressing a key.  (The exception to this would be the ESC and ENTER keys
  61.      if we had set the window's RESULT Flag too). NOTE: *NONE* of the RXVAL or
  62.      any LIST/DROP BOX stem variables, nor the Dimensions string for that
  63.      window have been setup if what caused RXDLG to return was a user pressing
  64.      a key.  (The exception to this would be the ESC and ENTER keys if we had
  65.      set the window's RESULT Flag too) */
  66.  
  67.    /* Figure out what key he pressed and display it */
  68.    SELECT
  69.     /* Regular (ie, printable key) */
  70.     WHEN RXID = 0 THEN DO
  71.         IF RXSUBID = ' ' THEN RXSUBID = 'SPACE' /* Just so that we see something for a SPACE */
  72.         RXSET '""' 2 1 'VAL' RXSUBID
  73.     END
  74.  
  75.     /* Regular (ie, printable key) with ALT key held down */
  76.     WHEN RXID = -1 THEN DO
  77.         /* NOTE: OS/2 siphons off ALT+SPACE to access a window's system
  78.         menu, but ALT+SHIFT+SPACE works here */
  79.         IF RXSUBID = ' ' THEN RXSUBID = 'SPACE' /* Just so that we see something for a SPACE */
  80.         RXSET '""' 2 1 'VAL' RXSUBID' + ALT'
  81.     END
  82.  
  83.     /* Regular (ie, printable key) with CTRL key held down */
  84.     WHEN RXID = -2 THEN DO
  85.         IF RXSUBID = ' ' THEN RXSUBID = 'SPACE' /* Just so that we see something for a SPACE */
  86.         RXSET '""' 2 1 'VAL' RXSUBID' + CTRL'
  87.     END
  88.  
  89.     /* Regular (ie, printable key) with ALT and CTRL both held down */
  90.     WHEN RXID = -3 THEN DO
  91.         IF RXSUBID = ' ' THEN RXSUBID = 'SPACE' /* Just so that we see something for a SPACE */
  92.         RXSET '""' 2 1 'VAL' RXSUBID' + ALT + CTRL'
  93.     END
  94.  
  95.     /* Virtual key */
  96.     WHEN RXID = -4 THEN DO
  97.         CALL ProcessKey
  98.         RXSET '""' 2 1 'VAL' str2
  99.     END
  100.  
  101.     /* Virtual Key with ALT key held down */
  102.     WHEN RXID = -5 THEN DO
  103.         CALL ProcessKey
  104.         RXSET '""' 2 1 'VAL' str2' + ALT'
  105.     END
  106.  
  107.     /* Virtual Key with CTRL key held down */
  108.     WHEN RXID = -6 THEN DO
  109.         CALL ProcessKey
  110.         RXSET '""' 2 1 'VAL' str2' + CTRL'
  111.     END
  112.  
  113.     /* Virtual Key with ALT and CTRL both held down */
  114.     WHEN RXID = -7 THEN DO
  115.         CALL ProcessKey
  116.         RXSET '""' 2 1 'VAL' str2' + ALT + CTRL'
  117.     END
  118.  
  119.     /* Virtual Key with SHIFT key held down */
  120.     WHEN RXID = -8 THEN DO
  121.         CALL ProcessKey
  122.         RXSET '""' 2 1 'VAL' str2' + SHIFT'
  123.     END
  124.  
  125.     /* Virtual Key with SHIFT + ALT key held down */
  126.     WHEN RXID = -9 THEN DO
  127.         CALL ProcessKey
  128.         RXSET '""' 2 1 'VAL' str2' + SHIFT + ALT'
  129.     END
  130.  
  131.     /* Virtual Key with SHIFT and CTRL both held down */
  132.     WHEN RXID = -10 THEN DO
  133.         CALL ProcessKey
  134.         RXSET '""' 2 1 'VAL' str2' + SHIFT + CTRL'
  135.     END
  136.  
  137.     /* Virtual Key with SHIFT and ALT and CTRL all held down */
  138.     WHEN RXID = -11 THEN DO
  139.         CALL ProcessKey
  140.         RXSET '""' 2 1 'VAL' str2' + SHIFT + ALT + CTRL'
  141.     END
  142.  
  143.     /* ESC */
  144.     WHEN RXID = -12 THEN DO
  145.         RXSET '""' 2 1 'VAL' 'ESC'
  146.     END
  147.  
  148.     /* Window's CLOSE ICON or ABORT */
  149.     WHEN RXID = -98 | RXID = -99 THEN DO
  150.         EXIT
  151.     END
  152.  
  153.     OTHERWISE
  154.         RXSET '""' 2 1 'VAL' 'RXID = 'RXID', RXSUBID = 'RXSUBID
  155.    END
  156.  
  157. /* Do another message loop */
  158. SIGNAL more
  159.  
  160. /* ========================== Done ========================== */
  161.  
  162. FAILURE:
  163.     /* NOTE: the variable RC contains the returned error message (not a number,
  164.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  165.     Because we used the default severity level, Rexx Dialog has already displayed
  166.     this error message to the enduser */
  167.     EXIT
  168. ERROR:
  169.     /* NOTE: the variable RC contains the returned error message (not a number,
  170.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  171.     Because we used the default severity level, Rexx Dialog has already displayed
  172.     this error message to the enduser */
  173.     EXIT
  174.  
  175.  
  176. ProcessKey:
  177.     SELECT
  178.     WHEN RXSUBID = 4 THEN str2 = 'Break'
  179.     WHEN RXSUBID = 5 THEN str2 = 'BackSpace'
  180.     WHEN RXSUBID = 6 THEN str2 = 'TAB'
  181.     WHEN RXSUBID = 7 THEN str2 = 'BackTAB'
  182.     WHEN RXSUBID = 13 THEN str2 = 'Pause'
  183.     WHEN RXSUBID = 14 THEN str2 = 'Caps Lock'
  184.     WHEN RXSUBID = 17 THEN str2 = 'Page Up'
  185.     WHEN RXSUBID = 18 THEN str2 = 'Page Down'
  186.     WHEN RXSUBID = 19 THEN str2 = 'End'
  187.     WHEN RXSUBID = 20 THEN str2 = 'Home'
  188.     WHEN RXSUBID = 21 THEN str2 = 'Left'
  189.     WHEN RXSUBID = 22 THEN str2 = 'Up'
  190.     WHEN RXSUBID = 23 THEN str2 = 'Right'
  191.     WHEN RXSUBID = 24 THEN str2 = 'Down'
  192.     WHEN RXSUBID = 25 THEN str2 = 'Print Screen'
  193.     WHEN RXSUBID = 26 THEN str2 = 'Insert'
  194.     WHEN RXSUBID = 27 THEN str2 = 'Delete'
  195.     WHEN RXSUBID = 28 THEN str2 = 'Scroll Lock'
  196.     WHEN RXSUBID = 29 THEN str2 = 'Num Lock'
  197.     WHEN RXSUBID = 31 THEN str2 = 'SysRq'
  198.     WHEN RXSUBID = 32 THEN str2 = 'F1'
  199.     WHEN RXSUBID = 33 THEN str2 = 'F2'
  200.     WHEN RXSUBID = 34 THEN str2 = 'F3'
  201.     WHEN RXSUBID = 35 THEN str2 = 'F4'
  202.     WHEN RXSUBID = 36 THEN str2 = 'F5'
  203.     WHEN RXSUBID = 37 THEN str2 = 'F6'
  204.     WHEN RXSUBID = 38 THEN str2 = 'F7'
  205.     WHEN RXSUBID = 39 THEN str2 = 'F8'
  206.     WHEN RXSUBID = 40 THEN str2 = 'F9'
  207.     WHEN RXSUBID = 41 THEN str2 = 'F10'
  208.     WHEN RXSUBID = 42 THEN str2 = 'F11'
  209.     WHEN RXSUBID = 43 THEN str2 = 'F12'
  210.     WHEN RXSUBID = 44 THEN str2 = 'F13'
  211.     WHEN RXSUBID = 45 THEN str2 = 'F14'
  212.     WHEN RXSUBID = 46 THEN str2 = 'F15'
  213.     WHEN RXSUBID = 47 THEN str2 = 'F16'
  214.     WHEN RXSUBID = 48 THEN str2 = 'F17'
  215.     WHEN RXSUBID = 49 THEN str2 = 'F18'
  216.     WHEN RXSUBID = 50 THEN str2 = 'F19'
  217.     WHEN RXSUBID = 51 THEN str2 = 'F20'
  218.     WHEN RXSUBID = 52 THEN str2 = 'F21'
  219.     WHEN RXSUBID = 53 THEN str2 = 'F22'
  220.     WHEN RXSUBID = 54 THEN str2 = 'F23'
  221.     WHEN RXSUBID = 55 THEN str2 = 'F24'
  222.     END
  223. RETURN
  224.