home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdlg11.zip / modal2.cmd < prev    next >
OS/2 REXX Batch file  |  1995-01-10  |  9KB  |  286 lines

  1. /* An example of a Modal Design. It creates a Main Window, and then several
  2.    Child Dialogs. Since all Children are MODAL, and we specify a specific window
  3.    to RXDLG, we can control the order that the user is allowed to interact with
  4.    the windows.
  5. */
  6.  
  7. /* Trap ERROR and FAILURE */
  8. SIGNAL ON ERROR
  9. SIGNAL ON FAILURE
  10.  
  11. /* ================ Create "Main Window" =============== */
  12. /* First Group is ENTRY */
  13. RXTYPE.1 = 'ENTRY'
  14.  
  15. /* Use of a control in this group causes RXDLG to return */
  16. RXFLAGS.1 = 'END'
  17.  
  18. /* Labels for each entry, and Groupbox. Note: 3rd entry has no label */
  19. RXLABEL.1 = 'Range|Second||Fourth|All'
  20.  
  21. /* Variable name where the text "typed into" the entries is stored */
  22. RXVAL.1 = 'TEXT'
  23.  
  24. /* TotalControls, ControlsPerLine, WidthOfControls */
  25. RXINFO.1 = '4 2 45'
  26.  
  27. /* Position of Group */
  28. RXX.1 = 65
  29. RXY.1 = 70
  30.  
  31. /* The text for the 4 entries */
  32. TEXT.1 = 'Hello'
  33. TEXT.2 = 'Hi'
  34. TEXT.3 = ' '         /* A blank entry initially */
  35. TEXT.4 = 'More text'
  36.  
  37. /* Default size and position (also gives us sizing and max button) */
  38. RXWIN1 = ''
  39.  
  40. RXDLG 1 '"Main Window"' 'RXWIN1' 'RESULT'
  41.  
  42.  
  43.  
  44.  
  45.  
  46. /* ================ Create "Pushbuttons"  dialog =============== */
  47. /* First Group is PUSH */
  48. RXTYPE.1 = 'PUSH'
  49.  
  50. /* Use of a control in this group causes RXDLG to return */
  51. RXFLAGS.1 = 'END'
  52.  
  53. /* Labels for each button, and Groupbox */
  54. RXLABEL.1 = 'One|Two|Three|Four|Choices'
  55.  
  56. /* TotalControls, ControlsPerLine, WidthOfControls */
  57. RXINFO.1 = '4 2 0'
  58.  
  59. /* Default choice for PushButton is nothing */
  60. RXVAL.1 = ''
  61.  
  62. /* Position */
  63. RXX.1 = 7
  64. RXY.1 = 6
  65.  
  66. /* Let Rexx Dialog close the dialog (ie, no NOCLOSE). Because we specified
  67.   MODAL, later when we pass this window title to RXDLG to perform user
  68.   interaction, the user will be able to interact only with this window */
  69. RXWIN2 = '190 108 8 8'
  70. RXDLG 1 '"Pushbuttons"' 'RXWIN2' 'MODAL'
  71.  
  72.  
  73.  
  74.  
  75. /* ================== Create "Spin Me" dialog ================= */
  76. /* First Group is SPIN */
  77. RXTYPE.1 = 'SPIN'
  78.  
  79. /* Default */
  80. RXFLAGS.1 = ''
  81.  
  82. /* Max, Min, Label for each slider, and groupbox */
  83. RXLABEL.1 = '255 0 Range 1:| 20 10 Range 2:|Try us'
  84.  
  85. /* Values for each slider */
  86. RXVAL.1 = '64 19'
  87.  
  88. /* TotalControls, ControlsPerLine, WidthOfControls */
  89. RXINFO.1 = '2 1 70'
  90.  
  91. /* Position */
  92. RXX.1 = 80
  93. RXY.1 = 18
  94.  
  95. RXWIN3 = '190 104 30 30'
  96. RXDLG 1 '"Spin Me"' 'RXWIN3' 'MODAL|SIZE|RESULT'
  97.  
  98.  
  99.  
  100.  
  101. /* ================= Create "List 1" Dialog ================== */
  102. RXTYPE.1 = 'LIST'
  103.  
  104. /* Default */
  105. RXFLAGS.1 = ''
  106.  
  107. /* Labels for each listbox, and Groupbox */
  108. RXLABEL.1 = 'Items: | Fruits: | List boxes'
  109.  
  110. /* Stem variable names to fetch the strings for each dropbox in the group */
  111. RXVAL.1 = 'BLORT|LIST'
  112.  
  113. /* TotalControls, ControlsPerLine, WidthOfControls, *AND* NumVisibleItems */
  114. RXINFO.1 = '2 1 100 4'
  115.  
  116. /* Position */
  117. RXX.1 = 10
  118. RXY.1 = 10
  119.  
  120. /* First List items */
  121. BLORT.1 = 'One'
  122. BLORT.2 = 'Two'
  123. BLORT.3 = 'Three'
  124. BLORT.4 = 'Four'
  125. BLORT.5 = 'Five'
  126. BLORT.6 = ' '  /* Marks the end of the list */
  127.  
  128. /* Second List items */
  129. LIST.1 = 'Bananas'
  130. LIST.2 = 'Oranges'
  131. LIST.3 = 'Grapes'
  132. LIST.4 = 'Apples'
  133. LIST.5 = ' '  /* Marks the end of the list */
  134.  
  135. RXWIN4 = '130 234 100 8'
  136. RXDLG 1 '"List 1"' 'RXWIN4' 'MODAL|RESULT'
  137.  
  138. /* Do user interaction. Because we specify "List 1", and its MODAL,
  139.    the user is limited to interacting with this window */
  140. RXDLG '"List 1"' /* No Operation means Operation 0 */
  141.  
  142. /* RXWIND now specifies which window woke us up. Because we specified MODAL,
  143.     then it must have been "Child 1" which caused RXDLG to return. The window
  144.     is no longer there because we didn't specify NOCLOSE for Child 1 */
  145. RXSAY '"'RXWIND'" woke us up.'
  146.  
  147. /* Did user press ESC or click the CLOSE ICON? */
  148. IF RXID < 0 THEN DO
  149.     RXSAY '"'RXWIND'" aborted.'
  150. END
  151.  
  152. /* Did user press the ENTER key while the window had the focus?
  153.    Note that we haven't setup a timeout, nor set the KEYS flag
  154.    of any window, so we don't need to check RXSUBID. It's always
  155.    going to be 10 (ie, ENTER) here if RXID is 0 */
  156. IF RXID = 0 THEN DO
  157.     RXSAY 'Pressed ENTER on "'RXWIND'".'
  158. END
  159.  
  160. /* If RXID is greater than 0, then this is the Group #, and RXSUBID is the
  161.    Control # (within that group), of the control that caused RXDLG to
  162.    return. NOTE: The first control within the first group (for this dialog) has a
  163.    Group # and Control # of 1 */
  164. IF RXID > 0 THEN DO
  165.    RXSAY 'Group #'RXID', Control #'RXSUBID' ended "'RXWIND'" dialog.'
  166. END
  167.  
  168. /* Display the selection for each of the 2 list boxes.
  169.     NOTE: This group is SINGLE SELECT */
  170. RXSAY '"'RXWIND'" Group 1, list 1 choice is "'BLORT.0'"'
  171. RXSAY '"'RXWIND'" Group 1, list 2 choice is "'LIST.0'"'
  172.  
  173.  
  174.  
  175.  
  176. /* ================ Do "Spin Me" ================ */
  177. /* Do user interaction. Because we specify "Spin Me", and its MODAL,
  178.    the user is limited to interacting with this window */
  179. RXDLG '"Spin Me"'
  180.  
  181. /* Report which window woke us up. It will be "Spin Me" */
  182. RXSAY '"'RXWIND'" woke us up.'
  183.  
  184. /* Did user press ESC or click the CLOSE ICON? */
  185. IF RXID < 0 THEN DO
  186.     RXSAY '"'RXWIND'" aborted.'
  187. END
  188.  
  189. /* Did user press the ENTER key? */
  190. IF RXID = 0 THEN DO
  191.     RXSAY 'Pressed ENTER on "'RXWIND'".'
  192. END
  193.  
  194. IF RXID > 0 THEN DO
  195.    /* Display the Group #, Control # of the control that caused RXDLG to return */
  196.    RXSAY 'Group #'RXID', Control #'RXSUBID' ended "'RXWIND'" dialog.'
  197. END
  198.  
  199. /* Display spin values */
  200. DO i = 1 TO 2
  201.     PARSE VAR RXVAL.1 knob RXVAL.1
  202.     RXSAY '"'RXWIND'" Group 1, Knob #'i' = 'knob
  203. END
  204.  
  205.  
  206.  
  207.  
  208. /* ================ Do "Pushbuttons" ================ */
  209. RXDLG '"Pushbuttons"' 1
  210.  
  211. /* Report which window woke us up. It will be "Pushbuttons" */
  212. RXSAY '"'RXWIND'" woke us up.'
  213.  
  214. /* Did user click the CLOSE ICON? ESC won't cause RXDLG to return
  215.    because we didn't set the RESULT Flag for the "Pushbuttons" dialog.
  216.    For the same reason, the ENTER key also does nothing */
  217. IF RXID < 0 THEN DO
  218.     RXSAY '"'RXWIND'" aborted.'
  219. END
  220.  
  221. IF RXID > 0 THEN DO
  222.    /* Display the Group #, Control # of the control that caused RXDLG to return */
  223.    RXSAY 'Group #'RXID', Control #'RXSUBID' ended "'RXWIND'" dialog.'
  224. END
  225.  
  226. /* Display chosen button #'s. NOTE: RXVAL could be "" for a PUSH/CHECK/RADIO
  227.     button group if the user didn't use any buttons and we didn't initially
  228.     set any of them (ie, RXVAL was a null string when the group was created),
  229.     or if there are ALL and NONE buttons and the user selected ALL. By setting
  230.     the RXVAL for a PUSH or RADIO BUTTON group to "" before calling RXDLG,
  231.     you can determine whether the user selected any of the buttons */
  232. IF RXVAL.1 > '' THEN RXSAY '"'RXWIND'" Group 1, pushed button #'RXVAL.1
  233. ELSE RXSAY '"'RXWIND'" Group 1, no button pushed.'
  234.  
  235.  
  236.  
  237.  
  238. /* ================ Do "Main Window" ================ */
  239. RXDLG '"Main Window"'
  240.   /* Operation=PROCESS_AND_END. Note that if we wanted to keep the main window
  241.      around so that we could keep calling RXDLG in a message loop, then we
  242.      wouldn't specify NOCLOSE, and do Operation 0 until such time as we
  243.      detected some condition  that prompted us to do Operation 3 or 4, and end
  244.      this script. For example, we could launch into that if we detect the ESC key
  245.      pressed or user clicked upon CLOSE ICON */
  246.  
  247. /* Report which window woke us up. It will be "Main Window" */
  248. RXSAY '"'RXWIND'" woke us up.'
  249.  
  250. /* Did user press ESC or CLOSE the window? */
  251. IF RXID < 0 THEN DO
  252.     RXSAY '"'RXWIND'" aborted.'
  253. END
  254.  
  255. /* Did user press the ENTER key while the dialog window had the focus? */
  256. IF RXID = 0 THEN DO
  257.     RXSAY 'Pressed ENTER on "'RXWIND'".'
  258. END
  259.  
  260. IF RXID > 0 THEN DO
  261.    /* Display the Group #, Control # of the control that caused RXDLG to return */
  262.    RXSAY 'Group #'RXID', Control #'RXSUBID' ended "'RXWIND'" dialog.'
  263. END
  264.  
  265. /* Display each entry's text, one entry at a time */
  266. DO i = 1 TO 4 /* There are 4 entries in this Group */
  267.     RXSAY '"'RXWIND'" Group 1, entry #'i' is "'TEXT.i'"'
  268. END
  269.  
  270.  
  271. /* ========================== Done ========================== */
  272. EXIT
  273.  
  274. FAILURE:
  275.     /* NOTE: the variable RC contains the returned error message (not a number,
  276.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  277.     Because we used the default severity level, Rexx Dialog has already displayed
  278.     this error message to the enduser */
  279.     EXIT
  280. ERROR:
  281.     /* NOTE: the variable RC contains the returned error message (not a number,
  282.     unless we use RXERR to set up Rexx Dialog to return error numbers instead).
  283.     Because we used the default severity level, Rexx Dialog has already displayed
  284.     this error message to the enduser */
  285.     EXIT
  286.