Guidance
指路人
g.yi.org
Software / Reginald / Examples / Loop2.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* This creates a Main Window, and numerous Child windows. Then it does a
 * message loop, letting the user interact with any of those windows. Some
 * of the windows have Groups which cause RXMSG() to return. Other windows have
 * the RESULT flag set so that the user can end by pressing ESC or ENTER. Of
 * course, clicking upon a CLOSE BOX always causes RXMSG to return. We use the
 * INTERPRET instruction and make sure that we have a corresponding label
 * (ie, subroutine) for every possible combination of RXWIND, RXID, and RXSUBID
 * that RXMSG() may return.
 */

ADDRESS null

/* Trap HALT and SYNTAX in any scripts we call which don't
 * trap HALT or SYNTAX themselves.
 */
OPTIONS 'TRAP'

/* Trap SYNTAX/ERROR/HALT, and ask for ERROR raising. Disable
 * ERROR raising for RXMSG(). We'll test for errors in our
 * loop
 */
SIGNAL ON HALT
SIGNAL ON SYNTAX
SIGNAL ON ERROR
CALL RXERR('ERROR|DISPLAY', '~!MSG')




/* ================ Create "Entries" Window =============== */
/* Default size and position. WindowID = 'RX' */
rx = ''

/* First Group is ENTRY */
rxtype.1 = 'ENTRY'

/* Multiple lines of text can be entered in each box */
rxflags.1 = 'MULTIPLE'

/* Labels for each entry, and Groupbox. Note: 2nd entry has no label */
rxlabel.1 = 'Type||All'

/* Variable name where the text "typed into" the entries is stored */
rxval.1 = 'TEXT'

/* RXINFO not needed */

/* ControlsPerLine, X Position, Y Position, Width, Height (ie, NumOfLines) */
rxpos.1 = '1 10 20 400 10'

/* The text for the 2 entries */
text.1 = 'Hello'
text.2 = ''         /* A blank entry initially */

/* Specify NOCLOSE (since we'll do the closing ourselves), but not
 * RESULT so that we don't siphon the ENTER key from the MULTIPLE
 * line ENTRYs. Also note that we set all of our windows as 'CHILD',
 * including even this first one. This means that none of the other
 * windows will open inside of this one, nor close when this one
 * closes.
 */
CALL RXCREATE('Rx', 1, 'Entries', 'NOCLOSE|CHILD|SETVAL')




/* =================== Create "Drop Stuff" window =================== */
/* Default size and position. WindowID = 'RX2' */
rx2 = ''

/* First Group is DROP */
rx2type.1 = 'DROP'

/* Changing value causes RXMSG() to return. Also, I can't type into the ENTRY */
rx2flags.1 = 'REPORT|NOBORDER|READONLY'

/* Labels for each dropbox, and Groupbox. Note: No label
 * for 3rd dropbox, nor Groupbox
 */
rx2label.1 = '&First | OS | |'

/* Stem variable names to fetch the strings for each dropbox in the group */
rx2val.1 = 'BLORT | CHOICE | LIST'

/* RXINFO not needed */

/* ControlsPerLine, X Position, Y Position, Width */
rx2pos.1 = '2 5 5 100'

/* First List items */
blort.1 = 'This is 1'
blort.2 = 'This is 2'
blort.3 = 'This is 3'
blort.4 = 'This is 4'
blort.5 = 'This is 5'
blort.6 = 'This is 6'
blort.7 = 'This is 7'
blort.8 = ''  /* Marks the end of the list */

/* Second List items */
choice.1 = 'Mac'
choice.2 = 'Windows'
choice.3 = ''  /* Marks the end of the list */

/* Third List items */
list.1 = 'Bananas'
list.2 = 'Oranges'
list.3 = 'Grapes'
list.4 = 'Apples'
list.5 = ''  /* Marks the end of the list */

/* Accelerators */
rx2accel = '1 1 _C_ F'

CALL RXCREATE('Rx2', 1, 'Drop Stuff', 'NOCLOSE|CHILD', rx2accel)




/* ================= Create "Indexes" window ================== */
/* Default size and position. WindowID = 'RX3' */
rx3 = ''

/* First Group is DROP */
rx3type.1 = 'DROP'

/* Give me index rather than the text for the selected item. If I typed
 * in something, not in the list, then that text is returned. Also,
 * cause RXMSG to return when control is used
 */
rx3flags.1 = 'INDEX'

/* Labels for each dropbox, and Groupbox */
rx3label.1 = 'Type Here:|Drop Me'

/* Stem variable names to fetch the strings for each dropbox in the group */
rx3val.1 = 'BLORT'

/* ControlsPerLine, X Position, Y Position, Width */
rx3pos.1 = '1 10 20 100'

/* First List items */
blort.1 = 'This is 1'
blort.2 = 'This is 2'
blort.3 = 'This is 3'
blort.4 = 'This is 4'
blort.5 = 'This is 5'
blort.6 = 'This is 6'
blort.7 = 'This is 7'
blort.8 = ''  /* Marks the end of the list */

CALL RXCREATE('Rx3', 1, 'Indexes', 'NOCLOSE|RESULT|CHILD')




/* ================= Create "List 1" window ================== */
/* Default size and position. WindowID = 'RX4' */
rx4 = ''

/* First Group is LIST */
rx4type.1 = 'LIST'

/* Give me index # of item, rather than the text for it.
 * Also cause RXMSG to return
 */
rx4flags.1 = 'INDEX|REPORT'

/* Labels for each listbox, and Groupbox */
rx4label.1 = 'Items: | Fruits: | List boxes'

/* Stem variable names to fetch the strings for each dropbox in the group */
rx4val.1 = 'BLORT|LIST'

/* ControlsPerLine, X Position, Y Position, Width, Height (NumVisibleItems) */
rx4pos.1 = '1 10 20 100 4'

/* First List items */
blort.1 = 'One'
blort.2 = 'Two'
blort.3 = 'Three'
blort.4 = 'Four'
blort.5 = 'Five'
blort.6 = ''  /* Marks the end of the list */

/* Second List items */
list.1 = 'Bananas'
list.2 = 'Oranges'
list.3 = 'Grapes'
list.4 = 'Apples'
list.5 = ''  /* Marks the end of the list */

CALL RXCREATE('RX4', 1, 'List 1', 'NOCLOSE|RESULT|CHILD')




/* ============== Create "MultiSelect Lists" window ================ */
/* Default size and position. WindowID = 'RX5' */
rx5 = ''

/* First Group is LIST */
rx5type.1 = 'LIST'

/* Flags */
rx5flags.1 = 'MULTIPLE|ALLNONE'

/* Labels for each listbox, and Groupbox. NOTE: No Groupbox */
rx5label.1 = 'Items: | Fruits:|'

/* Stem variable names to fetch the strings for each listbox in the group */
rx5val.1 = 'BLORT|LIST'

/* ControlsPerLine, X Position, Y Position, Width, Height (NumVisibleItems) */
rx5pos.1 = '1 10 5 100 4'

/* First List items */
blort.1 = 'One'
blort.2 = 'Two'
blort.3 = 'Three'
blort.4 = 'Four'
blort.5 = 'Five'
blort.6 = ''  /* Marks the end of the list */

/* Second List items */
list.1 = 'Bananas'
list.2 = 'Oranges'
list.3 = 'Grapes'
list.4 = 'Apples'
list.5 = 'Pears'
list.6 = 'Titties and Beer'
list.7 = ''  /* Marks the end of the list */

/* Second Group is PUSH */
rx5type.2 = 'PUSH'

/* A RESULT group of buttons. Also BOOL, so
 * return RXSUBID = 1 for even-numbered buttons, or 0 for
 * odd-numbered buttons.
 */
rx5flags.2 = 'BOOL|RESULT'

/* No groupbox */
rx5label.2 = ''

/* Give me "Cancel" and "Ok", no groupbox */
rx5label.2 = 'Cancel|Ok|'

/* No default */
rx5val = ''

/* ControlsPerLine, X Position, Y Position, Width=0 */
rx5pos.2 = '-1 3 210'

CALL RXCREATE('RX5', 2, 'MultiSelect Lists', 'NOCLOSE|RESULT|CHILD')




/* ================ Create "Electric Slide" window ================ */
/* Default size and position. WindowID = 'RX6' */
rx6 = ''

/* First Group is SLIDER */
rx6type.1 = 'SLIDER'

/* Print out value of slider knob as it moves */
rx6flags.1 = 'VALUE|REPORT|DELAY'

/* Label for each slider, and Groupbox */
rx6label.1 = 'Range 1:|Range 2:|Try us'

/* Initial values for slider knobs */
rx6val.1 = '64 32'

/* Min/Max values */
rx6info.1 = '-100 100 0 64'

/* ControlsPerLine, X Position, Y Position, Width */
rx6pos.1 = '1 10 20 142'

/* Use another TEXT Group to display the difference between the two sliders */
rx6type.2 = 'TEXT'

/* Default */
rx6flags.2 = 'NOBORDER'

/* Text lines */
rx6label.2 = '0|'

/* ControlsPerLine (phrases per line), X Position, Y Position, Width, BetweenPhrases. Note
 * we deliberately set WidthOfPhrase non-0 to allow enough width to accomodate
 * a range of text digits
 */
rx6pos.2 = '1 10 82 84 0'

CALL RXCREATE('RX6', 2, 'Electric Slide', 'NOCLOSE|CHILD')




/* ============= Message loop on the windows ============ */

/* 6 windows are open */
open = 6

DO WHILE open \= 0

   /* Because we have more than 1 window open and do not specify a WindowID
    * to RXMSG(), the user can interact with any of the open windows. Therefore,
    * we can't be sure which window will cause RXMSG() to return. We'll need to
    * check the RXWIND variable for that. RXMSG() will also set RXID and RXSUBID.
    * REXX Dialog may also set the dimensions variable if the window is resized.
    *
    * Also, because all of our windows are NOCLOSE here, REXX Dialog will set the
    * VAL variable for only the one control that caused RXMSG() to return (if
    * indeed a control was manipulated).
    *
    * NOTE: Here, all of our windows are NOCLOSE. RXMSG() will return if the user
    * clicks the CLOSE BOX of a window. But the window won't be automatically
    * closed. We'll do the closing ourselves with an explicit call to RXMSG() using
    * an 'END' operation. There's one gothca here. If we eventually close all of
    * the windows (including the Main Window), and make another call to RXMSG(),
    * then RXMSG() will report an ERROR (ie, "No open REXX Windows." error message).
    * So make sure that you have at least one window open before you ever call RXMSG()
    * (with the exception of simply calling RXMSG(,'END')). In fact, our way out
    * of here is to EXIT after we detect that the user has clicked on our first
    * Window's CLOSE BOX.
    */

   /* Wait on the window(s). We go to sleep while user manipulates windows,
    * until such time as the user presses ESC or ENTER, or tries to close a window
    * using its CLOSE BOX, or uses a RESULT Group or a Control within some Group
    * that has its REPORT Flag set, or an abort signal. Other things that could
    * cause RXMSG() to return are a window timeout, or if the user pressed a key
    * in a window with its KEYS Flag set, or user resizes a window with its NEWSIZE
    * flag set... but we haven't utilized those features here.
    */
   err = RXMSG()  /* NOTE: No WindowID or Operation means a PROCESS operation on any window */

   /* RXWIND now specifies which window woke us up. (The window is still
    * there because we specified NOCLOSE). RXID and RXSUBID tell us what
    * action caused RXMSG() to return. Handle this action.
    */
   IF err == '' THEN INTERPRET 'CALL' rxwind || '_'  || rxid || '_' || rxsubid

   /* Do the next interaction among all of the windows */
END /* WHILE open \= 0 */

EXIT





/* ============ CLOSE BOX for "Entries" window ============= */
rx__end:

   /* Display each entry's text, one entry at a time */
   DO i = 1 TO 2 /* There are 2 entries in this Group */
      CALL RXSAY('Group 1, entry #'||i||' is "'||text.i||'"')
   END

/* ========== CLOSE BOX for "Drop Stuff" window ============ */
rx2__end:

/* ============ CLOSE BOX for "Indexes" window ============= */
rx3__end:

/* ============= ESC key for "Indexes" window ============== */
rx3__esc:

/* ============= CLOSE BOX for "List 1" window ============= */
rx4__end:

/* ============== ESC key for "List 1" window ============== */
rx4__esc:

/* ======= CLOSE BOX for "MultiSelect Lists" window ======== */
rx5__end:

/* ======== ESC key for "MultiSelect Lists" window ========= */
rx5__esc:

/* ========= CLOSE BOX for "Electric Slide" window ========= */
rx6__end:

   /* Just close this one window */
   CALL RXMSG(rxwind, 'END')

   /* Indicate one less window open */
   open = open - 1

   /* Return to main loop */
   RETURN





  

/* ========= Group 1, Control 1 for "Electric Slide" window ========= */
rx6_1_1:

/* ========= Group 1, Control 2 for "Electric Slide" window ========= */
rx6_1_2:
   /* Get the values for the two sliders, and print the difference */
   CALL RXQUERY(rxwind, , , 1)
   PARSE VAR rx6val.1 knob rx6val.1
   CALL RXSET(rxwind, 'VALUE', knob - rx6val.1, 2, 1)

   /* Print out the value of the slider that was moved */
/*   CALL RXSET(RXWIND, 'VALUE', RX6VAL.1, 2, 1) */

   /* Return to main loop */
   RETURN





/* ========= Group 1, Control 1 for "Drop Stuff" window ========= */
rx2_1_1:

   /* Display the selection for the drop box which was selected */
   CALL RXSAY('Group 1, drop 1 choice is "'||blort.0||'"')

   /* Return to main loop */
   RETURN

/* ========= Group 1, Control 2 for "Drop Stuff" window ========= */
rx2_1_2:

   /* Display the selection for the drop box which was selected */
   CALL RXSAY('Group 1, drop 2 choice is "'||choice.0||'"')

   /* Return to main loop */
   RETURN

/* ========= Group 1, Control 3 for "Drop Stuff" window ========= */
rx2_1_3:

   /* Display the selection for the drop box which was selected */
   CALL RXSAY('Group 1, drop 3 choice is "'||list.0||'"')

   /* Return to main loop */
   RETURN





/* ============= ENTER key for "Indexes" window ============== */
rx3_0_enter:

   CALL RXSAY('ENTER key pressed for Indexes window')

   /* Close the window */
   CALL rx3__end()

   /* ENTER key sets the values of all Groups. So display them all */

/* ========= Group 1, Control 1 for "Indexes" window ========= */
rx3_1_1:

   /* Display the selection for the drop box which was selected */
   CALL RXSAY('"'||rxwind||'" Group 1, drop index is '||blort.0)

   /* Return to main loop */
   RETURN









/* ========= Group 1, Control 1 for "List 1" window ========= */
rx4_1_1:

   /* Display the selection for the list box which was selected */
   CALL RXSAY('Group 1, list 1 choice is "'||blort.0||'"')

   /* Return to main loop */
   RETURN

/* ========= Group 1, Control 2 for "List 1" window ========= */
rx4_1_2:

   /* Display the selection for the list box which was selected */
   CALL RXSAY('Group 1, list 2 choice is "'||list.0||'"')

   /* Return to main loop */
   RETURN

/* ============= ENTER key for "List 1" window ============== */
rx4_0_enter:

   CALL RXSAY('ENTER key pressed for List 1 window')

   /* Close the window */
   CALL rx4__end()

   /* ENTER key sets the values of all Groups. So display them all */
   CALL rx4_1_1()
   CALL rx4_1_2()

   /* Return to main loop */
   RETURN






/* ========= ENTER key for "MultiSelect Lists" window =========== */
rx5_0_enter:

   CALL RXSAY('ENTER key pressed for MultiSelect Lists window')

   /* ENTER key sets the VAL variables of all Groups, so display them */

/* ======== Ok RESULT button for "MultiSelect Lists" window ======== */
/* Because we specified the BOOL flag for this RESULT Group, any
 * SUCCESS button produces RXSUBID of 1. Also, since we set the
 * REPORT flag, all of the VAL variables are set for this window.
 */
rx5_2_1:
   /* Close the window */
   CALL rx5__end()

   /* Display the selections for BLORT (ie, first listbox in Group 1), one by one */
   DO i = 1 TO blort.0
      CALL RXSAY('Group 1, list 1, choice '||i||' is "'||blort.0.i||'"')
   END

   /* Display the selections for LIST, (ie, second listbox in Group 1) one by one */
   DO i = 1 TO list.0
      CALL RXSAY('Group 1, list 2, choice '||i||' is "'||list.0.i||'"')
   END

   /* Return to main loop */
   RETURN

/* ====== Cancel RESULT button for "MultiSelect Lists" window ====== */
/* Because we specified the BOOL flag for this RESULT Group, any
 * FAILURE button produces RXSUBID of 0.
 */
rx5_2_0:

   /* Close the window */
   CALL rx5__end()

   /* Return to main loop */
   RETURN







/* ==================== Error Handling ====================== */
syntax:
    CALL RXSAY(CONDITION('D') || '0D0A0D0A'x || SOURCELINE(sigl),,'Error '||condition('E')||' at line '||sigl)

halt:
error:
    /* NOTE: CONDITION('D') fetches error message. CONDITION('E') fetches the
     * error number. SIGL is the line number where the error occurred.
     * Rexx Dialog has already displayed a message since we specified DISPLAY
     * option.
     */
    CALL RXMSG(,'END')
    EXIT
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Mon 2018-7-23  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:08