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

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

  
/* This creates a Main Window, with 1 PUSH Group with 1 button labeled
 * "Time-out". When the user presses that button, we create a Child Window
 * just for the purpose of counting down a time-out. The Child contains a
 * TEXT Group with 1 blank line of text, is hidden, and we specify it as the
 * WindowID to RXMSG(). The point of this is so that we can do a timeout
 * without the user being able to interact during that timeout, as well as
 * not seeing the time-out window. We start up the time-out in the hidden
 * window, and pass that window to RXMSG, doing a PROCESS operation.
 * So, when RXMSG() returns, the window has timed out.
 */

ADDRESS null

/* 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 PUSH */
rxtype.1 = 'PUSH'

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

/* Label, no groupbox */
rxlabel.1 = 'Time-Out|'

/* */
rxval.1 = ''

/* PhrasesPerLine, X Position, Y Position, WidthOfPhrase=0, BetweenPhrases=0 */
rxpos.1 = '1 7 6'

/* Use another TEXT Group to display the elapsed timeout */
rxtype.2 = 'TEXT'

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

/* Text lines */
rxlabel.2 = '|'

/* PhrasesPerLine, X Position, Y Position, WidthOfPhrase, BetweenPhrases=0
 * we deliberately set WidthOfPhrase non-0 to allow enough width to accomodate
 * a variety of phrases
 */
rxpos.2 = '1 10 40 90'

/* Default size and position */
rx = ''
CALL RXCREATE('RX', 2, 'Main Window', 'NOCLOSE')

DO FOREVER

/* Do user interaction */
CALL RXMSG()

/* We only have 1 window (without KEYS or RESULT flag), with one pushbutton,
 * so it's either the CLOSE BOX or that button that caused RXMSG to return
 */

/* Did user click on the CLOSE BOX? */
IF rxid == '' THEN SIGNAL HALT

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

/* Default */
rx2flags.1 = 'NOBORDER'

/* No controls. (ie, An empty group) */
rx2label.1 = ''

rx2pos.1 = '1 1 1'

rx2 = '1 1 0 0'
CALL RXCREATE('RX2', 1, 'Child 1')

/* ========================================================= */

/* Hide the child window. The window is only 1 by 1 pixel, so it's
 * pretty hard to see down there in lower left corner of Main, but...
 */
CALL RXSET('RX2', 'HIDE')

/* Setup a timeout (in Child 1) for 5000 milliseconds (ie, 5 seconds) */
CALL RXSET('RX2', 'TIME', 5000)

/* Print "Timing Out..." in the main window */
CALL RXSET(, 'VALUE', 'Timing Out...', 2, 1)

/* Do the timeout. Specify the WindowID of "Child 1", but because it's
 * hidden, the user can't interact with any windows. Because we didn't specify
 * NOCLOSE, this window is closed at the end of the time-out
 */
CALL RXMSG('RX2')

/* Print "All Done!" in the main window */
CALL RXSET(, 'VALUE', 'All Done!', 2, 1)

END /* DO FOREVER */





/* ==================== 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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2018-11-17  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:25