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

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

  
/* An example of a Modal Design. It creates a Main Window, and then a
 * Child Window. Since we specify the child's name as the WindowTitle
 * arg to RXMSG(), then the user is limited to interacting with that
 * window.
 */

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

/* Trap SYNTAX/ERROR/HAT, and ask for ERROR raising */
SIGNAL ON HALT
SIGNAL ON SYNTAX
SIGNAL ON ERROR
CALL RXERR('ERROR|DISPLAY')



/* =============== Create "Main Window" ================= */
/* First Group is RADIO */
rxtype.1 = 'RADIO'

/* Use of a control in this group causes RXMSG to return. Also let RXMSG
 * label the controls with numbers
 */
rxflags.1 = 'REPORT'

/* Labels and groupbox */
rxlabel.1 = '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|Pick one'

/* Initially select button 1 */
rxval.1 = '1'

/* ControlsPerLine, X Position, Y Position, Width=0 */
rxpos.1 = '4 7 22'

/* Default size and position */
rx = ''

CALL RXCREATE('RX', 1, 'Main Window', 'RESULT')





/* ================== Create "Child 1" window ================== */
/* First Group is PUSH */
rx2type.1 = 'PUSH'

/* Use of a control in this group causes RXMSG to return */
rx2flags.1 = 'REPORT'

/* Labels for each button, and Groupbox */
rx2label.1 = 'One|Two|Three|Four|Choices'

/* Default choice for PushButton is nothing */
rx2val.1 = ''

/* ControlsPerLine, X Position, Y Position, Width=0 */
rx2pos.1 = '2 7 22'

rx2 = ''

CALL RXCREATE('RX2', 1, 'Child 1', 'RESULT|CHILD|MIN')







/* Do user interaction. Because we specify a WindowTitle, we get modal,
 * state, and the user is limited to interacting with this window
 */
CALL RXMSG('RX2') /* Omitting the Operation means PROCESS */

/* RXWIND now specifies which window woke us up. Because we specified WindowTitle,
 * then it must have been "Child 1" which caused RXMSG to return. The window
 * is no longer there because we didn't specify NOCLOSE for Child 1
 */
CALL RXSAY('"'||rxwind||'" woke us up.')

/* Did user press ESC or click on the CLOSE ICON? */
IF rxid == '' THEN DO
   CALL RXSAY('"'||rxwind||'" closed.')
END

/* Did user press the ENTER key while the window had the focus?
 * Note that we haven't setup a timeout, nor set the KEYS flag
 * of any window, or set NEWSIZE flag, etc, so we don't need to
 * check RXSUBID. It's always going to be 'ENTER' here if RXID is 0
 */
ELSE IF rxid == '0' THEN DO
   CALL RXSAY('Pressed ENTER on "'||rxwind||'".')
END

/* If RXID is not '' or 0, then this is the Group #, and RXSUBID is the
 * Control # (within that group), of the control that caused RXMSG to
 * return. NOTE: The first control within the first group (for this window)
 * has a Group # and Control # of 1 */
ELSE DO
    CALL RXSAY('Group #'||rxid||', Control #'||rxsubid||' ended "'||rxwind||'" window.')
END

/* At this point, we could call RXMSG() with no parameters to let the user
 * interact with Main Window. But let's just end
 */
/*
DO UNTIL RXID == ''
   CALL RXMSG()
END
*/
CALL RXMSG(,'END')
EXIT




/* ==================== 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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2017-6-22  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:10