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

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

  
/* An example using RXSET with a MENU Group. We create the window with
 * a MENU Group that contains an "Items" heading and a "My Item" item
 * under it. It also contains an ENTRY Group with one control. The window
 * is created (with NOCLOSE). When the user types some text into the ENTRY
 * and presses return, we add this as another sub-item under "My Item"
 * (upto a total of 10 items).
 *
 * Trying typing in various labels. You can also append a | character,
 * followed by MARK to add a checkmark.
 */

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

/* MENU Group */
rxlabel.1 = 'MENU'

/* Default */
rxflags.1 = ''

/* Add an 'Items' heading with a 'My Item' item */
menu.0 = 'Items'
menu.1 = 'My Item|10'
menu.2 = ''

/* Let's reserve the first 10 positions under 'My Item'. In this
 * way, if we had subsequent sub-items under 'My Item', we wouldn't
 * alter those positions by adding or deleting subitems at these 10
 * positions. Also, we don't alter any subsequent menu label numbers
 * for any help book)
 */
menu.1.1 = '|10'

/* An ENTRY to type in a menu item's text */
rxtype.2 = 'ENTRY'
rxflags.2 = 'REPORT'
rxlabel.2 = 'Menu text:|'
rxpos.2 = '-1 5 5 150'
rxval.2 = 'TEXT'

text.1 = ''

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

/* Specify 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', 2, 'Main Window', 'NOCLOSE')

/* Initially, no menu items added */
items = 0

DO FOREVER

   /* Do user interaction. */
   CALL RXMSG()

   /* IF user clicked upon CLOSE ICON, exit. */
   IF rxid == '' THEN SIGNAL HALT

   /* If he selected the ENTRY, then add another menu item. */
   IF rxid == '2' & items < 10 THEN DO

      /* Next position under 'Items'. */
      items = items + 1

      /* Add the text at that position. */
      CALL RXSET(, 'ADD', text.1, 1, '1.1.' || items)

   END

   IF rxid == '1' THEN CALL RXSAY('Selected menu item: ' || rxsubid)

END





/* ==================== 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 2017-6-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:35:09