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

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

  
/* This creates a Main Window with a Group of 1 DROP BOX with the
 * REPORT flag set.  Whenever the user types 'del' into the entry, RXMSG
 * returns, and we delete all of the items in the DROP BOX's list.  If
 * the user types 'add' item, we add several items to the list.
 */

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

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

/* Label for control. No Groupbox */
rxlabel.1 = '|'

/* REXX variable where initial text stored */
rxval.1 = 'STRS'

/* ControlsPerLine, X Position, Y Position, Width, NumVisibleItems */
rxpos.1 = '1 5 5 90 6'

/* Text */
strs.1 = 'all'
strs.2 = 'none'
strs.3 = 'something'
strs.4 = 'more'
strs.5 = 'del'
strs.6 = ''

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

/* NOCLOSE since we want to close the window ourselves. No
 * RESULT Flag, so the ESC and ENTER keys do nothing, and we
 * don't have to bother checking for those
 */
CALL RXCREATE('RX', 1, 'RXSET() ADD/DELETE - DROP', 'NOCLOSE')

DO FOREVER

/* Do user interaction */
CALL RXMSG()

/* Did user click upon the CLOSE BOX? If so, then exit */
IF rxid == '' THEN SIGNAL HALT

/* Since there is only 1 group and 1 control, we know that the DROP BOX caused
 * RXMSG to return. Check the selection. If the user typed 'del', then delete
 * all items.  We could pass each item to delete in a separate call to RXSET
 * with the DEL command, but by omitting the Value arg, DEL will automatically
 * delete all items in the list. If the user typed 'add', then we ADD a few
 * items to the list
 */

/* If 'del' was typed, delete all items in the list */
IF strs.0 = 'del' THEN DO
   CALL RXSAY('Deleting list...')
   CALL RXSET(, 'DELETE', , 1, 1)
END

/* If 'add' was typed, add some items to the list */
ELSE IF strs.0 = 'add' THEN DO
   CALL RXSAY('Creating list...')

   /* First let's hide the list. If we were adding a lot of
    * items, this could speed things up
    */
   CALL RXSET(, 'HIDE', , 1, 1)

   /* Delete whatever is currently in the list */
   CALL RXSET(, 'DELETE', , 1, 1)

   /* Add items 'Item 1', 'Item 2', 'Item 3', and 'Item 4'. Add them at the end of the list */
   DO i = 1 TO 4
      CALL RXSET(, 'ADD', 'Item' i, 1, 1)
   END

   /* OK, show the list now */
   CALL RXSET(, 'SHOW', , 1, 1)
END

/* See if this item is already in the list by trying to select it.
 * If it isn't, we'll add it to the list.
 */
ELSE DO
   /* Temporarily disable the VALUE category of error messages
    * so that, in case the item isn't in the list, REXX Dialog
    * won't trigger SYNTAX.
    */
   CALL RXERR(,'~!VALUE')

   /* Is it in the list? */
   IF RXSET(, 'VALUE', strs.0, 1, 1) \= '' THEN DO

      /* No, it isn't. Add it to the end of the list now, and reselect it */
      CALL RXSET(, 'ADD', strs.0, 1, 1)
      CALL RXSET(, 'VALUE', strs.0, 1, 1)

   END

   /* Enable the VALUE category of error messages */
   CALL RXERR(,'!VALUE')

END

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 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-08-27 06:46:24