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

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* An example of using RXFILE() to pick out a multiple filenames. We create
 * a Main Window with a PUSH button to click on which brings up the
 * File Dialog using RXFILE(). Note that we could have instead put a
 * File -> Open menu item in our Main Window. In fact, you don't even
 * need a Main Window open in order to call RXFILE() and bring up the
 * File Dialog. You can simply call RXFILE() without first opening
 * any other window.
 */

/* Toss away the return from a function if
 * we don't assign it to a variable
 */
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')





/* ====================== 'Main Window' ======================= */
rxtype.1 = 'PUSH'

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

/* Label */
rxlabel.1 = 'Example of RXFILE.|'

/* INFO not needed */

/* Default */
rxval.1 = ''

/* ControlsPerLine, X Position, Y Position */
rxpos.1 = '1 7 6'

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

/* Open Main Window */
CALL RXCREATE('RX', 1, 'Main Window')

/* Do interaction with Main Window */
CALL RXMSG()

/* Since we have only one PUSHBUTTON, and didn't specify the 'RESULT' nor
 * 'KEYs' window flags, nor set a timeout for the window, then the only two
 * things that could have caused RXMSG() to return are the user closing
 * the window, or pushing that one button. And since we don't have the
 * 'NOCLOSE' window flag, either action has already closed the window
 */

/* Did user click the CLOSE BOX? Note that we don't need to do an
 * RXMSG(,'END') because we have no windows open with the 'NOCLOSE'
 * flag
 */
IF rxid == '' THEN EXIT

/* Ok, he must have pushed the button. Present the File Dialog */

/* Store the filename in the variable FN. Initialize it to 'file.rex' so
 * that one is initially selected. But, we could instead not assign any
 * value, or assign an empty string, to not provide an initial selection.
 */
fn = 'file.rex'

/* Here are our file extensions that we filter -- .rex and all files */
extensions = 'REXX scripts (*.rex) | *.rex | All files (*.*) | *.*'

/* Do the File Dialog, allowing MULTIPLE selection */
err = RXFILE('FN', 'MULTIPLE|HIDEREADONLY|EXISTING|PATH|DIR', 'Pick out a file', extensions)

/* Check for OK */
IF err == "" THEN DO

   /* Display each chosen filename */
   DO i = 1 TO fn.0
      CALL RXSAY(fn.i)
   END

END

/* RC must be 'Cancel', because all other errors jumped to SYNTAX */
ELSE CALL RXSAY('User cancelled!')

/* Done. Note that we don't need to do an RXMSG(,'END') because we have
 * no windows open with the 'NOCLOSE' flag
 */
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
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:03