home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / T.H.E. / Prefs / THE next >
Text File  |  2000-01-11  |  41KB  |  1,274 lines

  1. /*
  2.    $VER: RA_THE.rexx 1.3 (25.12.99) Copyright (c) Nils Görs.
  3.  
  4.    Thanks to William Parker for writing AWNP, for teaching me how to
  5.    use it and for the help.
  6.  
  7.    This script is for editing the Tools-Menu and Hotkey functions from Workbench.
  8.  
  9.    The script creates an ARexx-Script that will be placed in WBStartup. You have
  10.    to create an Icon for this script to be executed automatically.
  11.  
  12.    This script needs:
  13.     - AWNPipe: ver 2.22 or newer.
  14.     - workbench.library v44.1414 or newer.
  15. */
  16.  
  17. Scriptname = "Sys:WBStartup/setKeyAndMenu"
  18.  
  19. QuickEnd = "YES"    /* quit T.H.E with [ESC] (YES|NO) */
  20. Horizline = "NO"    /* use horizontal lines? (YES|NO) */
  21.  
  22. mxchars = 256         /* Maximum number of character/digits in argument gadget. */ 
  23. /*
  24. *** Please don't change anything under this line
  25. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  26. options results
  27.  
  28. parse source . . called .
  29. PARSE ARG PubScreen
  30. IF PubScreen = "" THEN PubScreen = "Workbench"
  31.  
  32. ADDRESS workbench
  33.  
  34. call _InitAll()
  35. call BuildGUI()
  36.  
  37. Loop:
  38. do while ~eof(ca)
  39. call topipe('con')
  40. in= readln(ca)
  41.  
  42. /*listviews need five values parsed. For string gadgets you want everything after in2 */
  43. parse var in in1 in2 in3 in4 in5 .
  44. parse var in . . infromstring
  45.     SELECT
  46.         WHEN in1='arexx' then call RxHost()
  47.         WHEN in1='iconify' then call iconify()
  48.         WHEN in1='gadget' then call gadget()
  49.         WHEN in1='menu' then call menu()
  50.         WHEN in1='close' then CALL MYEXIT()
  51.         WHEN in1='key' then call keystroke()
  52.     OTHERWISE
  53.         NOP
  54.     END
  55.  
  56. END
  57. EXIT
  58.  
  59. _InitAll:
  60. IF show('P','T.H.E.') then DO
  61.   address T.H.E. uniconify
  62.   address T.H.E. activate
  63.   exit
  64. END
  65.  
  66. IF ~show('L','rexxsupport.library') THEN
  67. IF ~addlib('rexxsupport.library',0,-30,0) THEN
  68. exit(20)
  69.  
  70. /* Version check */
  71. ca = "THE"
  72. IF SHOWLIST('H', 'AWNPIPE') THEN res=open(ca,"awnpipe:T.H.E./-2022/xc")
  73.     if res ~= 1 then do
  74.         requesterdata='`requestchoice "T.H.E. Error"
  75. "To use this program you need AWNPipe:*n        (Vers 2.22 or newer). " "OK"`'
  76.         CALL ShellResult(requesterdata)
  77.         exit
  78.     end
  79.  
  80. checkversion = '`version workbench.library`'
  81. IF WORD(ShellResult(checkversion),2) < "44.1414" THEN DO
  82.         requesterdata='`requestchoice "T.H.E. Error"
  83.  "To use this program you need OS 3.5*n      (Vers 44.1414 or newer). " "OK"`'
  84.         CALL ShellResult(requesterdata)
  85.         EXIT
  86. END
  87.  
  88.  
  89. /* Init variables */
  90. TRUE  = 1
  91. FALSE = 0
  92. NL = '0a'x
  93. TM_entries = ""
  94. HK_Entries = ""
  95. TM_STRINGNAMEVALUE = ""
  96. TM_STRINGTITLEVALUE = ""
  97. TM_STRINGSHORTCUTVALUE = ""
  98. TM_StringCommandValue    = "rexx:"
  99. TM_StringArgumentValue    = ""
  100.  
  101. HK_StringNameValue = ""
  102. HK_StringHotkeyValue = ""
  103. HK_StringCommandValue    = "rexx:"
  104. HK_StringArgumentValue    = ""
  105.  
  106. HK_counter = 0
  107. TM_counter = 0
  108.  
  109. currentpage = 0
  110.  
  111. Hotkeys = "SHIFT|LSHIFT|RSHIFT|AMIGA|LAMIGA|RAMIGA|ALT|LALT|RALT|ESC|RETURN|DEL|HELP|CTRL|CAPSLOCK|NUMERICPAD|ENTER|BACKSPACE|SPACE|COMMA|UPSTROKE|F1|F2|F3|F4|F5|F6|F7|F8|F10"
  112.  
  113. /*
  114. ** Set current dir
  115. */
  116.  
  117.  PARSE SOURCE . . . progdir .
  118.  
  119.  booll = LENGTH(progdir)
  120.  booli= LASTPOS(":",progdir)
  121.  boolh= LASTPOS("/",progdir)
  122.  
  123.  
  124. IF boolh > booli THEN progdir = SUBSTR(progdir,1,boolh-1)
  125. IF boolh == 0 THEN progdir = SUBSTR(progdir,1,booli)
  126.  
  127. IF RIGHT(progdir,1) ~= ':' THEN progdir2 = progdir||'/'
  128.             ELSE progdir2 = progdir
  129.  
  130.  CALL PRAGMA('D',progdir)
  131.  
  132. /*
  133. ** Read default strings, open locale.library and catalog
  134. */
  135.  
  136. CALL BuildInLanguage                    /* install build-in language */
  137.  
  138. IF ~SHOW('LIBRARIES','locale.library') THEN
  139.    CALL ADDLIB('locale.library',0,-30,0)
  140.  
  141. IF SHOW('LIBRARIES','locale.library') THEN DO
  142.     id='req'pragma('id')                /* get current language */
  143.     address command 'rxset' id '`echo $language`' 
  144.     language=getclip(id)
  145.     call setclip(id,'')
  146.  
  147.    IF language ~= '' THEN DO
  148.     catalog = OPENCATALOG(progdir2'catalogs/'language'/THE.catalog','english',0)
  149.         IF catalog = 0 THEN
  150.         catalog = OPENCATALOG(progdir2'THE.catalog','english',0)
  151.    END
  152.  
  153.    IF catalog = 0 THEN
  154.     catalog = OPENCATALOG('THE.catalog','english',0)
  155. END
  156. RETURN
  157.  
  158. */
  159. /*******************************************************************************
  160. ** Text aus dem Catalog-File auslesen, falls vorhanden
  161. *******************************************************************************/
  162.  
  163. localestring:
  164.    PARSE ARG stringnumber
  165.  
  166.    IF catalog ~= 0 THEN
  167.       RETURN(GETCATALOGSTR(catalog,stringnumber,strings.stringnumber))
  168.    ELSE
  169.       RETURN(strings.stringnumber)
  170.  
  171. /*
  172. ***
  173. */
  174. iconify:
  175. IF in2=1 THEN call topipe('id 0 s 32')        /* iconify   */
  176.      ELSE call topipe('id 0 s 64')        /* uniconify */
  177. RETURN
  178.  
  179. keystroke:
  180. call topipe('id 0 s 256')
  181.     SELECT
  182.         WHEN in2 = 69 THEN IF quickend = "YES" THEN CALL MYEXIT()
  183.         WHEN in2 = 76 | in2 = 62 THEN DO    /* Cursor up,  NUM 8 */
  184.             IF currentpage = 0 THEN lister = TM_ListViewID        /* ToolsMenu or Hotkey Page? */
  185.                 ELSE lister = HK_ListViewID
  186.  
  187.             call topipe('id 'lister 'up')
  188.             IF currentpage = 0 THEN DO                /* ToolsMenu */
  189.             IF tm_entries = "" THEN BREAK                /* no entries! */
  190.  
  191.                 call topipe2('id' TM_ListViewID 'read')
  192.                 tm_currentnode = WORD(in,3)
  193.                 TM_currentCounter = FIND(TM_entries,TM_currentnode)
  194.  
  195.                 IF TM_currentCounter <= 0 THEN DO
  196.                     TM_currentCounter = 1
  197.                     TM_currentNode = WORD(TM_entries,1)
  198.                 END
  199.                 ELSE TM_currentnode = WORD(TM_entries,TM_currentCounter)
  200.  
  201.                 call _DisableTMGads(FALSE)
  202.                 CALL _UpdateTMStrings(TM_currentnode)
  203.             END
  204.             ELSE DO                            /* Hotkey Menu */
  205.             IF hk_entries = "" THEN BREAK                /* no entries! */
  206.                 call topipe2('id' HK_ListViewID 'read')
  207.                 hk_currentnode = WORD(in,3)
  208.  
  209.                 HK_currentCounter=FIND(HK_entries,HK_currentNode)
  210.  
  211.                 IF HK_currentCounter <= 0 THEN DO
  212.                     HK_currentCounter = 1
  213.                     HK_currentNode = WORD(HK_entries,1)
  214.                 END
  215.                 ELSE HK_currentnode = WORD(HK_entries,HK_currentCounter)
  216.                 call _DisableHKGads(FALSE)
  217.                 CALL _UpdateHKStrings(HK_currentnode)
  218.             END
  219.         END
  220.         WHEN in2 = 77 | in2 = 30 THEN DO    /* Cursor down,  NUM 2 */
  221.             IF currentpage = 0 THEN lister = TM_ListViewID        /* ToolsMenu or Hotkey Page? */
  222.                 ELSE lister = HK_ListViewID
  223.  
  224.             call topipe('id 'lister 'down')
  225.             IF currentpage = 0 THEN DO                /* ToolsMenu */
  226.             IF tm_entries = "" THEN BREAK                /* no entries! */
  227.                 call topipe2('id' TM_ListViewID 'read')
  228.                 tm_currentnode = WORD(in,3)
  229.  
  230.                 TM_currentCounter=FIND(TM_entries,TM_currentNode)
  231.                 IF TM_currentCounter <= 0 THEN DO
  232.                     TM_currentCounter = 1
  233.                     TM_currentNode = WORD(TM_entries,1)
  234.                 END
  235.                 ELSE DO
  236.                     TM_currentnode = WORD(TM_entries,TM_currentCounter)
  237.                     IF TM_Name.TM_currentnode = "TM_NAME." THEN DO
  238.                         TM_currentCounter = TM_currentCounter -1
  239.                         TM_currentnode = WORD(TM_entries,TM_currentCounter)
  240.                     END
  241.                 END
  242.                 call _DisableTMGads(FALSE)
  243.                 CALL _UpdateTMStrings(TM_currentnode)
  244.             END
  245.             ELSE DO                            /* Hotkey Menu */
  246.             IF hk_entries = "" THEN BREAK                /* no entries! */
  247.                 call topipe2('id' hk_ListViewID 'read')
  248.                 hk_currentnode = WORD(in,3)
  249.                 HK_currentCounter=FIND(HK_entries,hk_currentNode)
  250.  
  251.                 IF HK_currentCounter <= 0 THEN DO
  252.                     HK_currentCounter = 1
  253.                     HK_currentNode = WORD(HK_entries,1)
  254.                 END
  255.                 ELSE DO
  256.                     HK_currentnode = WORD(HK_entries,HK_currentCounter)
  257.                     IF HK_Name.HK_currentnode = "HK_NAME." THEN DO
  258.                         HK_currentCounter = HK_currentCounter -1
  259.                         HK_currentnode = WORD(HK_entries,HK_currentCounter)
  260.                     END
  261.  
  262.                 END
  263.                 call _DisableHKGads(FALSE)
  264.                 CALL _UpdateHKStrings(HK_currentnode)
  265.             END
  266.         END
  267.         WHEN in2 = 66 THEN DO        /* TAB */
  268.             currentpage=bitxor('1'x,currentpage)
  269.             call topipe('id' pageid 's' currentpage 'refresh')
  270.         END
  271.  
  272.         WHEN in2 = 61 THEN DO        /* Home */
  273.             IF currentpage = 0 THEN DO
  274.                 lister = TM_ListViewID        /* ToolsMenu or Hotkey Page? */
  275.                 call topipe2('id' TM_ListViewID 'read')
  276.                 check = WORD(in,3)
  277.                 LPos=WORD(tm_entries,1)
  278.                 IF Lpos ~= check THEN DO
  279.                     call _DisableTMGads(FALSE)
  280.                     CALL _UpdateTMStrings(LPos)
  281.                     call topipe('id' lister 's' lpos)
  282.                     TM_currentnode = LPos
  283.                 END
  284.             END
  285.             ELSE DO
  286.                 lister = HK_ListViewID
  287.                 call topipe2('id' HK_ListViewID 'read')
  288.                 check = WORD(in,3)
  289.                 LPos=WORD(hk_entries,1)
  290.                 IF Lpos ~= check THEN DO
  291.                     call _DisableHKGads(FALSE)
  292.                     CALL _UpdateHKStrings(LPos)
  293.                     call topipe('id' lister 's' lpos)
  294.                     HK_currentnode = LPos
  295.                 END
  296.             END
  297.         END
  298.  
  299.         WHEN in2 = 29 THEN DO        /* End */
  300.             IF currentpage = 0 THEN DO
  301.                 call topipe2('id' TM_ListViewID 'read')
  302.                 check = WORD(in,3)
  303.                 lister = TM_ListViewID        /* ToolsMenu or Hotkey Page? */
  304.                 LPos=WORD(tm_entries,WORDS(tm_entries))
  305.                 IF Lpos ~= check THEN DO
  306.                     call _DisableTMGads(FALSE)
  307.                     CALL _UpdateTMStrings(LPos)
  308.                     call topipe('id' lister 's' lpos)
  309.                     TM_currentnode = LPos
  310.                 END
  311.             END
  312.             ELSE DO
  313.                 lister = HK_ListViewID
  314.                 call topipe2('id' HK_ListViewID 'read')
  315.                 check = WORD(in,3)
  316.                 LPos=WORD(hk_entries,WORDS(hk_entries))
  317.                 IF Lpos ~= check THEN DO
  318.                     call _DisableHKGads(FALSE)
  319.                     CALL _UpdateHKStrings(LPos)
  320.                     call topipe('id' lister 's' lpos)
  321.                     HK_currentnode = LPos
  322.                 END
  323.             END
  324.         END
  325.  
  326.     OTHERWISE
  327.         NOP
  328.     END
  329. call topipe('id 0 s 512')
  330. RETURN
  331.  
  332. menu:
  333. SELECT
  334.     WHEN in2 = 0 & in3 = 0 THEN DO
  335.         call topipe('id 0 s 256')
  336.         requesterdata='`requestchoice "RA_THEinfo" "RA_THE.rexx 1.3 (25.12.99)*n© by Nils Görs*n<nils@goers.line.org>*n*nGUI build with AWNPipe*n© by William Parker*n<bill@amitrix.com>" "OK"`'
  337.         CALL ShellResult(requesterdata)
  338.         call topipe('id 0 s 512')
  339.     END
  340.     WHEN in2 = 0 & in3 = 2 THEN DO
  341.         call topipe('id 0 s 256')
  342.         requesterdata='`requestchoice "T.H.E." "'localestring(MSG_Request_Quit)'" "'localestring(MSG_Request_Yes)'" PUBSCREEN='pubscreen'`'
  343.         IF ShellResult(requesterdata) = 1 THEN CALL MYEXIT
  344.         call topipe('id 0 s 512')
  345.     END
  346.  
  347.     WHEN in2 = 1 & in3 = 0 THEN DO
  348.     IF currentpage = 0 THEN call _DisableTMGads(TRUE)
  349.             ELSE call _DisableHKGads(TRUE)
  350.  
  351.         call topipe('id 0 s 256')
  352.         IF currentpage = 1 THEN DO
  353.             IF hk_counter >0 THEN DO
  354.                 call topipe('id' HK_ListviewID 'removenode')
  355.                 CALL HKClearStrings()
  356.                 hk_entries = ""
  357.                 hk_counter = 0
  358.             END
  359.         END
  360.         ELSE DO
  361.             IF tm_counter >0 THEN DO
  362.                 call topipe('id' TM_ListviewID 'removenode')
  363.                 CALL TMClearStrings()
  364.                 tm_entries = ""
  365.                 tm_counter = 0
  366.             END
  367.         END
  368.         call topipe('id 0 s 512')
  369.     END
  370.  
  371.     WHEN in2 = 1 & in3 = 1 THEN DO            /* last saved */
  372.     call topipe('id 0 s 256')
  373.         IF currentpage = 0 THEN DO
  374.             call _DisableTMGads(TRUE)
  375.             call _UpdateTMStrings(TM_currentnode)
  376.             call topipe('id' TM_ListviewID 'removenode')
  377.             tm_entries = ""
  378.             tm_counter = 0
  379.             call topipe('id' TM_ListviewID 'Selected=0')    /* Disable selected entry */
  380.             TM_currentNode = 0                /* Set pointer to first list entry */
  381.  
  382.             call GetToolsMenu()
  383.         END
  384.         ELSE DO
  385.             call _DisableHKGads(TRUE)
  386.             call _UpdateHKStrings(HK_currentnode)
  387.             call topipe('id' HK_ListviewID 'removenode')
  388.             hk_entries = ""
  389.             hk_counter = 0
  390.             call topipe('id' HK_ListviewID 'Selected=0')    /* Disable selected entry */
  391.             HK_currentNode = 0                /* Set pointer to first list entry */
  392.  
  393.             call GetHotkeys()
  394.         END
  395.     call topipe('id 0 s 512')
  396.     END
  397.     OTHERWISE
  398.         NOP
  399. END
  400. RETURN
  401.  
  402. Gadget:
  403. SELECT
  404. /*
  405. *** ListView
  406. */
  407.     WHEN in2 = pageid THEN currentpage = in3
  408.  
  409.     WHEN in2 = TM_ListViewID  THEN DO
  410.         TM_currentnode=in5    /* remember the curently selected node for future use...*/
  411.         CALL _DisableTMGads(FALSE)
  412.         CALL _UpdateTMStrings(in5)
  413.     END
  414.  
  415.     WHEN in2 = HK_ListViewID  THEN DO
  416.         HK_currentnode=in5    /* remember the curently selected node for future use...*/
  417.         IF FIND(HK_entries,HK_currentnode) = 0 THEN RETURN
  418.  
  419.         IF HK_Key.in5 = "" THEN HK_HotkeyValue = ""
  420.                 ELSE HK_HotkeyValue = HK_Key.in5
  421.  
  422.         call _DisableHKGads(FALSE)
  423.         CALL _UpdateHKStrings(in5)
  424.     END
  425.  
  426. /*
  427. *** ToolsMenu Gadgets
  428. */
  429.     WHEN in2 = TM_AddID THEN DO
  430.         IF TM_Counter = 62 THEN DO
  431.             call topipe('id 0 s 256')
  432.             requesterdata='`requestchoice "T.H.E." "'localestring(MSG_TooManyEntries)'" "Ok!" PUBSCREEN='pubscreen'`'
  433.             CALL ShellResult(requesterdata)
  434.             call topipe('id 0 s 512')
  435.             RETURN
  436.         END
  437.         currentPos=FIND(TM_entries,TM_currentnode)
  438.         currentPos.bak = currentPos
  439.  
  440.         IF currentpos ~= 0 THEN tarGID= WORD(tm_entries,currentpos.bak)
  441.                     ELSE tarGID = -1
  442.  
  443.         Node_ID = topipe('tar='tarGID 'id 'TM_ListViewID 'addnode gt "'localestring(MSG_New_Name)'|'localestring(MSG_New_Title)'||rexx:" page 'pageid)
  444.  
  445.         TM_name.Node_ID = localestring(MSG_New_Name)
  446.         TM_title.Node_ID = localestring(MSG_New_Title)
  447.         TM_Shortcut.Node_ID = ""
  448.         mt_Command = "rexx:"
  449.         mt_Args = ""
  450.         call parseTMArgs()            /* write command and args */
  451.  
  452.         TM_CURRENTNODE=Node_ID
  453.  
  454.         IF currentPos ~= 0 & currentPos < TM_counter THEN DO
  455.             currentPos = WORDINDEX(TM_entries,currentpos+1)-1    /* next entry and char back */
  456.             tm_entries = INSERT(TM_currentnode||" ",tm_entries,currentPos)
  457.         END
  458.         ELSE TM_Entries = TM_Entries Node_ID        /* add GID to TM_entries */
  459.  
  460.         TM_counter = TM_counter + 1        /* one more entry in list! */
  461.  
  462.         call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
  463.         CALL _DisableTMGads(FALSE)
  464.         CALL _UpdateTMStrings(TM_CURRENTNODE)
  465.  
  466. /*
  467.         call topipe('id 'TM_StringNameID' s=0') /* auto activation forces system-crash */
  468. */
  469.     END
  470.  
  471.     WHEN in2 = TM_RemoveID THEN DO
  472.     IF TM_currentnode = "TM_CURRENTNODE" THEN RETURN
  473.         IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  474.  
  475.         CALL _DisableTMGads(TRUE)
  476.         CALL topipe('id' TM_currentnode 'removenode')
  477.         CALL TMClearStrings()
  478.  
  479.         TM_counter = TM_counter - 1
  480.         TM_entries = DELWORD(TM_entries,FIND(TM_entries,TM_currentnode),1)
  481.     END
  482.  
  483.     WHEN in2 = TM_CloneID THEN DO
  484.         IF TM_Counter = 62 THEN DO
  485.             call topipe('id 0 s 256')
  486.             requesterdata='`requestchoice "T.H.E." "'localestring(MSG_TooManyEntries)'" "Ok!" PUBSCREEN='pubscreen'`'
  487.             CALL ShellResult(requesterdata)
  488.             call topipe('id 0 s 512')
  489.             RETURN
  490.         END
  491.  
  492.         IF TM_currentnode = "TM_CURRENTNODE" THEN RETURN        /* no selected enty */
  493.         IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  494.  
  495.         currentPos=FIND(TM_entries,TM_currentnode)
  496.  
  497.         tarGID = WORD(tm_entries,FIND(TM_entries,TM_currentnode))
  498.  
  499.         TM_CommandArgs = STRIP(TM_Command.tarGID TM_Args.tarGID)
  500.  
  501.         Node_ID = topipe('tar='tarGID 'id 'TM_ListViewID 'addnode gt "'TM_name.tarGID'|'TM_title.tarGID'|'TM_Shortcut.tarGID'|'TM_CommandArgs '"page 'pageid)
  502.  
  503.         TM_name.Node_ID = TM_name.tarGID
  504.         TM_title.Node_ID = TM_title.tarGID
  505.         TM_Shortcut.Node_ID = TM_Shortcut.tarGID
  506.         TM_Command.Node_ID = TM_Command.tarGID
  507.         TM_Args.Node_ID = TM_Args.tarGID
  508.  
  509.         TM_CURRENTNODE=Node_ID
  510.  
  511.         IF currentPos ~= 0 & currentPos < TM_counter THEN DO
  512.             currentPos = WORDINDEX(TM_entries,currentpos+1)-1    /* next entry and char back */
  513.             tm_entries = INSERT(TM_currentnode||" ",tm_entries,currentPos)
  514.         END
  515.         ELSE TM_Entries = TM_Entries Node_ID        /* add GID to TM_entries */
  516.  
  517.         TM_counter = TM_counter + 1        /* one more entry in list! */
  518.  
  519.         call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
  520.         CALL _UpdateTMStrings(TM_CURRENTNODE)
  521.  
  522.     END
  523.  
  524.     WHEN in2 = TM_UpID THEN DO
  525.         IF TM_CURRENTNODE = "TM_CURRENTNODE" THEN RETURN
  526.         IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  527.  
  528.         currentPos = FIND(TM_entries,TM_currentnode)
  529.         prevEntry = WORD(TM_entries,currentPos-1)     /* get previous entry */
  530.         IF prevEntry = "" THEN RETURN            /* Top of list */
  531.  
  532.         CALL swapTM
  533.  
  534.         TM_CURRENTNODE = prevEntry
  535.  
  536.         call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
  537.         CALL _UpdateTMStrings(TM_currentnode)
  538.  
  539.     END
  540.  
  541.     WHEN in2 = TM_DownID THEN DO
  542.         IF TM_CURRENTNODE = "TM_CURRENTNODE" THEN RETURN
  543.         IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  544.  
  545.         currentPos = FIND(TM_entries,TM_currentnode)
  546.         prevEntry = WORD(TM_entries,currentPos+1)     /* get previous entry */
  547.         IF prevEntry = "" THEN RETURN            /* Top of list */
  548.         CALL swapTM
  549.         TM_CURRENTNODE = prevEntry
  550.         call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
  551.         CALL _UpdateTMStrings(TM_currentnode)
  552.     END
  553.  
  554.  
  555. /*
  556. *** get StringGadget value for Tools-Menu
  557. */
  558.     WHEN in2 = TM_StringNameID THEN DO
  559.         IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
  560.         TM_StringNameValue = DELWORD(in,1,2)
  561.  
  562.         IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
  563.                         ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
  564.  
  565.         IF topipe2('id 'TM_currentnode' address') ~= 0 THEN    /* check if GID exists */
  566.             call topipe('id 'TM_currentnode' gt "'TM_StringNameValue'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
  567.             TM_Name.TM_currentnode = TM_StringNameValue
  568.     END
  569.     WHEN in2 = TM_StringTitleID THEN DO
  570.         IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
  571.         TM_StringTitleValue = DELWORD(in,1,2)
  572.         IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
  573.                         ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
  574.         IF topipe2('id 'TM_currentnode' address') ~= 0 THEN    /* check if GID exists */
  575.             call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_StringTitleValue'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
  576.             TM_Title.TM_currentnode = TM_StringTitleValue
  577.     END
  578.     WHEN in2 = TM_StringShortcutID THEN DO
  579.         IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
  580.         IF in3 = '"' THEN in3 = ""        /* don't except " as Shortcut! */
  581. /*
  582.         IF LENGTH(in3) > 0 THEN in3 = LEFT(in3,1)
  583.                     ELSE in3 = ""
  584. */
  585.         TM_StringShortcutValue = in3
  586.         IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
  587.                         ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
  588.         IF topipe2('id 'TM_currentnode' address') ~= 0 THEN    /* check if GID exists */
  589.             call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_StringShortCutValue'|'commandArgs'"')
  590.             call topipe('id 'TM_StringShortCutID 'gt "'TM_StringShortcutValue'" ref')
  591.             TM_ShortCut.TM_currentnode = TM_StringShortCutValue
  592.     END
  593.     WHEN in2 = TM_GetFileID THEN DO
  594.         IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
  595.         TM_StringCommandValue = STRIP(COMPRESS(DELWORD(in,1,3),'"'))
  596.         IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_StringCommandValue TM_Args.TM_currentnode
  597.                         ELSE commandArgs = TM_StringCommandValue||TM_Args.TM_currentnode
  598.         IF topipe2('id 'TM_currentnode' address') ~= 0 THEN    /* check if GID exists */
  599.             call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
  600.             TM_Command.TM_currentnode = TM_StringCommandValue
  601.     END
  602.     WHEN in2 = TM_StringArgsID THEN DO
  603.         IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
  604.         TM_StringArgsValue = STRIP(COMPRESS(DELWORD(in,1,2),'"'))
  605.         IF TM_StringArgsValue ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_StringArgsValue
  606.                         ELSE commandArgs = TM_Command.TM_currentnode||TM_StringArgsValue
  607.         IF topipe2('id 'TM_currentnode' address') ~= 0 THEN    /* check if GID exists */
  608.             call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
  609.             TM_Args.TM_currentnode = TM_StringArgsValue
  610.     END
  611.  
  612. /*
  613. *** Hotkey Gadgets
  614. */
  615.     WHEN in2 = HK_AddID THEN DO
  616.         Node_ID = topipe('id 'HK_ListViewID 'addnode gt "'localestring(MSG_New_Name)'|'localestring(MSG_New_Hotkey)'|rexx:" page 'pageid)
  617.  
  618.         hk_Name = localestring(MSG_New_Name)
  619.         hk_key = ""
  620.         hk_Command = "rexx:"
  621.         CALL WriteHKStem()
  622.         HK_CURRENTNODE=Node_ID
  623.         call topipe2('id 'HK_ListViewID' s 'HK_CURRENTNODE)
  624.  
  625.         call _DisableHKGads(FALSE)
  626.         CALL _UpdateHKStrings(HK_CURRENTNODE)
  627.         IF HK_Key.HK_CURRENTNODE = "" THEN HK_HotkeyValue = ""
  628.                 ELSE HK_HotkeyValue = HK_Key.HK_CURRENTNODE
  629. /*
  630.         call topipe('id 'HK_StringNameID' s=0') /* auto activation forces system-crash */
  631. */
  632.     END
  633.  
  634.     WHEN in2 = HK_CloneID THEN DO
  635.         IF HK_currentnode = "HK_CURRENTNODE" THEN RETURN        /* no selected enty */
  636.         IF topipe2('id 'HK_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  637.  
  638.         currentPos=FIND(HK_entries,HK_currentnode)
  639.  
  640.         tarGID = word(HK_entries,FIND(HK_entries,HK_currentnode))
  641.  
  642.         HK_CommandArgs = STRIP(HK_Command.tarGID HK_Args.tarGID)
  643.  
  644.         Node_ID = topipe('tar='tarGID 'id 'HK_ListViewID 'addnode gt "'HK_name.tarGID'|'HK_key.tarGID'|'HK_CommandArgs '"page 'pageid)
  645.  
  646.         HK_name.Node_ID = HK_name.tarGID
  647.         HK_key.Node_ID = HK_Key.tarGID
  648.         HK_Command.Node_ID = HK_Command.tarGID
  649.         HK_Args.Node_ID = HK_Args.tarGID
  650.  
  651.         HK_CURRENTNODE=Node_ID
  652.         IF currentPos ~= 0 & currentPos < HK_counter THEN DO
  653.             currentPos = WORDINDEX(HK_entries,currentpos+1)-1    /* next entry and char back */
  654.             HK_entries = INSERT(HK_currentnode||" ",HK_entries,currentPos)
  655.         END
  656.         ELSE HK_Entries = HK_Entries Node_ID        /* add GID to HK_entries */
  657.  
  658.         HK_counter = HK_counter + 1        /* one more entry in list! */
  659.  
  660.         call topipe2('id 'HK_ListViewID' s 'HK_CURRENTNODE)
  661.         CALL _UpdateHKStrings(HK_CURRENTNODE)
  662.  
  663.     END
  664.  
  665.     WHEN in2 = HK_RemoveID THEN DO
  666.     IF HK_currentnode = "HK_CURRENTNODE" THEN RETURN
  667.         IF topipe2('id 'HK_currentnode' address') = 0 THEN RETURN    /* check if GID exists */
  668.         CALL topipe('id' HK_currentnode 'removenode')
  669.         call _DisableHKGads(TRUE)
  670.         CALL HKClearStrings()
  671.  
  672.         HK_counter = HK_counter - 1
  673.         HK_entries = DELWORD(HK_entries,FIND(HK_entries,HK_currentnode),1)
  674.     END
  675.  
  676. /*
  677. *** get Stringgadget value for Hotkeys
  678. */
  679.     WHEN in2 = HK_StringNameID THEN DO
  680.         IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
  681.         HK_StringNameValue = DELWORD(in,1,2)
  682.         IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
  683.                         ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
  684.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN    /* check if GID exists */
  685.             call topipe('id 'HK_currentnode' gt "'HK_StringNameValue'|'HK_Key.HK_currentnode'|'commandArgs'"')
  686.         HK_Name.HK_currentnode = HK_StringNameValue
  687.     END
  688.  
  689.     WHEN in2 = HK_CancelBoxID THEN DO
  690.         IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
  691.  
  692.         call topipe('id 'HK_StringHotKeyID 'gt "" ref')
  693.  
  694.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN DO/* check if GID exists */
  695.             call topipe('id 'HK_currentnode' gt "'HK_name.HK_currentnode'|""|'commandArgs'"')
  696.             HK_Key.HK_currentnode = ""
  697.         END
  698.         HK_StringHotkeyValue = ""
  699.     END
  700.  
  701.     WHEN in2 = HK_StringHotKeyID THEN DO
  702.     in3 = DELWORD(in,1,2)
  703.         IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
  704.         IF in3 = "" THEN HK_StringHotkeyValue = ""
  705.                 ELSE HK_StringHotkeyValue = in3
  706.         IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
  707.                         ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
  708.         call topipe('id 'HK_StringHotKeyID' gt "'HK_StringHotkeyValue'" ref')
  709.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
  710.             call topipe('id 'HK_currentnode' gt "'HK_name.HK_currentnode'|'HK_StringHotkeyValue'|'commandArgs'"')
  711.  
  712.         HK_Key.HK_currentnode = HK_StringHotKeyValue
  713.     END
  714.  
  715.     WHEN in2 = HK_chooserID THEN DO
  716.         addHotkey = WORD(TRANSLATE(Hotkeys," ","|"),in3+1)
  717.         IF HK_currentnode ~= "HK_CURRENTNODE" & HK_currentnode ~= -1 THEN HK_StringHotkeyValue = HK_Key.HK_currentnode
  718.                             ELSE HK_CURRENTNODE = -1
  719.  
  720.         IF HK_StringHotkeyValue = "" THEN HK_StringHotkeyValue = addhotkey
  721.                   ELSE HK_StringHotkeyValue = HK_StringHotkeyValue ||" "|| addHotkey
  722.  
  723.         IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
  724.                         ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
  725.  
  726.         call topipe('id 'HK_StringHotKeyID 'gt "'HK_StringHotkeyValue'"')
  727.  
  728.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN    /* check if GID exists */
  729.             call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_StringHotkeyValue'|'commandArgs'"')
  730.             HK_Key.HK_currentnode = HK_StringHotKeyValue
  731.     END
  732.  
  733.     WHEN in2 = HK_GetFileID THEN DO
  734.         IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
  735.         HK_StringCommandValue = STRIP(COMPRESS(DELWORD(in,1,3),'"'))
  736.         IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_StringCommandValue HK_Args.HK_currentnode
  737.                         ELSE commandArgs = HK_StringCommandValue||HK_Args.HK_currentnode
  738.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN    /* check if GID exists */
  739.             call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_Key.HK_currentnode'|'commandArgs'"')
  740.             HK_Command.HK_currentnode = HK_StringCommandValue
  741.     END
  742.     WHEN in2 = HK_StringArgsID THEN DO
  743.         IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
  744.         HK_StringArgsValue = STRIP(COMPRESS(DELWORD(in,1,2),'"'))
  745.         IF HK_StringArgsValue ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_StringArgsValue
  746.                         ELSE commandArgs = HK_Command.HK_currentnode||HK_StringArgsValue
  747.         IF topipe2('id 'HK_currentnode' address') ~= 0 THEN    /* check if GID exists */
  748.             call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_Key.HK_currentnode'|'commandArgs'"')
  749.             HK_Args.HK_currentnode = HK_StringArgsValue
  750.     END
  751. /*
  752. *** Save|Use|Cancel gadgets
  753. */
  754.     WHEN in2 = TM_SaveID | in2 = HK_SaveID THEN DO
  755.         CALL _Save
  756.         CALL _RemoveMenuHotkeys
  757.         RX scriptname
  758.         CALL MYEXIT
  759.     END
  760.     WHEN in2 = TM_UseID | in2 = HK_UseID THEN DO
  761.         CALL _RemoveMenuHotkeys
  762.         Scriptname.bak = Scriptname
  763.         Scriptname = "t:myscript"
  764.         CALL _Save
  765.         RX scriptname
  766.         IF exists(scriptname) THEN DELETE scriptname
  767.         Scriptname = Scriptname.bak
  768.         CALL MYEXIT
  769.     END
  770.  
  771.     WHEN in2 = TM_CancelID | in2 = HK_CancelID THEN CALL MYEXIT()
  772.  
  773. OTHERWISE
  774. NOP
  775. END
  776. return
  777.  
  778. BuildGUI:
  779. /* define window */
  780. call topipe('Title="'localestring(MSG_TitleName)'" st="Workbench Screen" Icontitle=THE iconifygadget sendkeys defaultgadgets modify verticaly SpaceInner SpaceOuter topleft activate ii "'called'" pubscreen='pubscreen)
  781.  
  782. call topipe('ARexx gt "T.H.E.|uniconify|iconify|quit|activate|front|back"')
  783.  
  784. /* define the menues */
  785. call topipe('menu gt "'localestring(MSG_MenuT_Project)'|'localestring(MSG_Menu_About)'|-|'localestring(MSG_Menu_Quit)'"')
  786. call topipe('menu gt "'localestring(MSG_MenuT_Edit)'|'localestring(MSG_Menu_Remove)'|'localestring(MSG_Menu_LastSaved)'"')
  787.  
  788. /* define the gadgets*/
  789. pageid = topipe('clicktab ctl "'localestring(MSG_MAIN_ToolsMenu)'|'localestring(MSG_MAIN_HotkeyMenu)'"')
  790.  
  791. call topipe('layout b=0 v page' pageid)
  792. call topipe('layout si so b=7 gt="'localestring(MSG_TM_ToolsMenu)'"')
  793. IF horizLine = "YES" THEN TM_ListViewID = topipe('listbrowser lbl="'localestring(MSG_TM_LV_Title)'" arrows h v minh=120 minw=300 showtitles')
  794.              ELSE TM_ListViewID = topipe('listbrowser lbl="'localestring(MSG_TM_LV_Title)'" arrows v  minh=120 minw=300 showtitles')
  795.  
  796. call topipe(le)
  797.  
  798. call topipe('layout hori so b=0 weih=0')
  799. TM_AddID = topipe('button gt "'localestring(MSG_Button_Add)'"')
  800. TM_RemoveID = topipe('button gt "'localestring(MSG_Button_Remove)'" dis=1')
  801. TM_CloneID = topipe('button gt "'localestring(MSG_Button_Clone)'" dis=1')
  802. TM_UpID = topipe('button gt "'localestring(MSG_Button_Up)'" dis=1')
  803. TM_DownID = topipe('button gt "'localestring(MSG_Button_Down)'" dis=1')
  804. call topipe(le)
  805.  
  806. call topipe('layout v si so weih 0')
  807. call topipe('label gt "'localestring(MSG_String_Name)'" ua')
  808. TM_StringNameID = topipe('string chl lj tc dis=1')
  809. call topipe('label gt "'localestring(MSG_String_Title)'" ua')
  810. TM_StringTitleID = topipe('string chl lj tc dis=1')
  811. call topipe('label gt "'localestring(MSG_String_ShortCut)'" ua')
  812. TM_StringShortCutID = topipe('string chl lj tc maxchars=2 dis=1')
  813. call topipe('label gt "'localestring(MSG_String_Command)'" ua')
  814. TM_GetFileID = topipe('getfile chl fn "rexx:" dis=1')
  815. call topipe('label gt "'localestring(MSG_String_Argument)'" ua')
  816. TM_StringArgsID = topipe('string chl lj tc dis=1 maxchars='mxchars)
  817. call topipe(le)
  818.  
  819. call topipe('layout b=0 v si so weih 0')
  820. call topipe('button b=7 minh 2')
  821. call topipe('layout b=0 h si so weih 0')
  822. TM_SaveID = topipe('button weiw 0 gt "'localestring(MSG_Button_Save)'"')
  823. call topipe('space')
  824. TM_UseID = topipe('button weiw 0 gt "'localestring(MSG_Button_Use)'"')
  825. call topipe('space')
  826. TM_CancelID = topipe('button weiw 0 gt "'localestring(MSG_Button_Cancel)'"')
  827. call topipe(le)
  828. call topipe(le)
  829. call topipe(le)
  830.  
  831. call topipe('layout b 0 v page' pageid)
  832. call topipe('layout si so b=7 gt="'localestring(MSG_HK_Hotkey)'"')
  833. IF horizLine = "YES" THEN HK_ListViewID = topipe('listbrowser lbl="'localestring(MSG_HK_LV_Title)'" arrows h v minh=120 minw=300 showtitles')
  834.              ELSE HK_ListViewID = topipe('listbrowser lbl="'localestring(MSG_HK_LV_Title)'" arrows v minh=120 minw=300 showtitles')
  835. call topipe(le)
  836.  
  837. call topipe('layout hori so b=0 weih=0')
  838. HK_AddID = topipe('button gt "'localestring(MSG_Button_Add)'"')
  839. call topipe('space')
  840. HK_CloneID = topipe('button gt "'localestring(MSG_Button_Clone)'" dis=1')
  841. call topipe('space')
  842. HK_RemoveID = topipe('button gt "'localestring(MSG_Button_Remove)'" dis=1')
  843. call topipe(le)
  844.  
  845. call topipe('layout v si so weih 0')
  846. call topipe('label gt "'localestring(MSG_String_Name)'" ua')
  847. HK_StringNameID = topipe('string chl lj tc dis=1')
  848. call topipe('label gt "'localestring(MSG_String_HotKey)'" ua')
  849. call topipe('layout chl bj b=0')
  850. HK_StringHotKeyID = topipe('string chl lj tc dis=1')
  851. HK_CancelBoxID = topipe('button autobutton=4 weiw=0 dis=1')
  852. HK_ChooserID = topipe('chooser chl lj maxn=31 dis=1 cl='hotkeys)
  853. call topipe('le')
  854. call topipe('label gt "'localestring(MSG_String_Command)'" ua')
  855. HK_GetFileID = topipe('getfile chl fn "rexx:" dis=1')
  856. call topipe('label gt "'localestring(MSG_String_Argument)'" ua')
  857. HK_StringArgsID = topipe('string chl lj tc dis=1 maxchars='mxchars)
  858. call topipe(le)
  859.  
  860. call topipe('layout b=0 v si so weih 0')
  861. call topipe('button b=7 minh 2')
  862. call topipe('layout b=0 h si so weih 0')
  863. HK_SaveID = topipe('button weiw 0 gt "'localestring(MSG_Button_Save)'"')
  864. call topipe('space')
  865. HK_UseID =  topipe('button weiw 0 gt "'localestring(MSG_Button_Use)'"')
  866. call topipe('space')
  867. HK_CancelID = topipe('button weiw 0 gt "'localestring(MSG_Button_Cancel)'"')
  868. call topipe(le)
  869. call topipe(le)
  870.  
  871. /*open the GUI window*/
  872. call topipe("open")
  873.  
  874. /* now create the listview entries */
  875. call topipe('id 0 s 256')
  876. call GetToolsMenu()
  877. call GetHotkeys()
  878. call topipe('id 0 s 512')
  879. RETURN
  880.  
  881.  
  882. topipe:
  883. /* this routine does error checking on lines written to pipe.*/
  884. /*get line to output*/
  885. parse arg out
  886.  
  887. /* write to the pipe*/
  888. call writeln(ca,out)
  889.  
  890. /*get responce and parse it.*/
  891. in=readln(ca)
  892. parse var in res1 res2 .
  893.  
  894. /* if all is ok return the second part of the responce (usualy the GID)*/
  895. if res1='ok' then return(res2)
  896.  
  897. /* something went wrong, we notify the user then exit */
  898. /*show problem line and responce (reponce may be just a blank line)*/
  899. say 'error from: 'out
  900. say '  responce: ' in
  901. exit
  902.  
  903. topipe2:
  904. /* this routine does error checking on lines written to pipe.*/
  905.  
  906. /*get line to output*/
  907. parse arg out
  908.  
  909. /* write to the pipe*/
  910. call writeln(ca,out)
  911.  
  912. /*get responce and parse it.*/
  913. in=readln(ca)
  914. parse var in res1 res2 .
  915. return(res1)
  916.  
  917. /*
  918.   my very personal ARexx host
  919. */
  920. RxHost:
  921.     call topipe2("rc 0")
  922. SELECT
  923.     WHEN in2 = 0 THEN call topipe('id 0 s 64')        /* uniconify */
  924.     WHEN in2 = 1 THEN call topipe('id 0 s 32')        /* iconify */
  925.     WHEN in2 = 2 THEN CALL MYEXIT(0)            /* quit */
  926.     WHEN in2 = 3 THEN call topipe('id 0 s 1')        /* activate */
  927.     WHEN in2 = 4 THEN call topipe('id 0 s 2')        /* window to front */
  928.     WHEN in2 = 5 THEN call topipe('id 0 s 4')        /* window to back */
  929. OTHERWISE
  930.     call topipe2("rc 5")
  931. END
  932.  
  933. RETURN
  934.  
  935. MyExit:
  936. CALL CLOSECATALOG(catalog)
  937. EXIT
  938. /*
  939. */
  940. GetToolsMenu:
  941. GETATTR MENUCOMMANDS.COUNT
  942. ToolsMenu.0 = result
  943.  
  944. call topipe('id 'TM_ListViewID 'list 0')
  945.  
  946. DO i = 0 to ToolsMenu.0 -1
  947.     GETATTR MENUCOMMANDS.i.NAME
  948.     mt_name = result
  949.     GETATTR MENUCOMMANDS.i.TITLE
  950.     mt_title = result
  951.     GETATTR MENUCOMMANDS.i.SHORTCUT
  952.     mt_shortcut = result
  953.     GETATTR MENUCOMMANDS.i.COMMAND
  954.     mt_command = result
  955.     /* get the GID of the node, save the contents of the node for further reference. */
  956.     Node_ID = topipe('id 'TM_ListViewID 'addnode gt "'mt_name'|'mt_title'|'mt_shortcut'|'mt_command'" page 'pageid)
  957.  
  958.     CALL WriteTMStem()
  959. END
  960. call topipe('id 'TM_ListViewID 'list 1 page' pageid)
  961. RETURN
  962.  
  963. GetHotkeys:
  964. GETATTR KEYCOMMANDS.COUNT
  965. Hotkeys.0 = result
  966. call topipe('id 'HK_ListViewID 'list 0')
  967. DO i = 0 to Hotkeys.0 -1
  968.     GETATTR KEYCOMMANDS.i.NAME
  969.     hk_name = result
  970.     GETATTR KEYCOMMANDS.i.KEY
  971.     hk_key = result
  972.     GETATTR KEYCOMMANDS.i.COMMAND
  973.     hk_command = result
  974.  
  975.     /* get the GID of the node, save the contents of the node for further reference. */
  976.     Node_ID = topipe('id 'HK_ListViewID 'addnode gt "'hk_name'|'hk_key'|'hk_command'" page 'pageid)
  977.     call writeHKStem()
  978. END
  979. call topipe('id 'HK_ListViewID 'list 1 page' pageid)
  980. RETURN
  981.  
  982. WriteTMStem:
  983.     TM_name.Node_ID=mt_name
  984.     TM_title.Node_ID=mt_title
  985.     TM_Shortcut.Node_ID=mt_shortcut
  986.     call parseTMArgs()            /* write command and args */
  987.  
  988.     TM_counter = TM_counter + 1
  989.     TM_Entries = TM_Entries Node_ID        /* add GID to TM_entries */
  990. RETURN
  991.  
  992. TMClearStrings:
  993.     CALL topipe('id 'TM_StringNameID ' dis='TMGadStatus 'gt ""')
  994.     CALL topipe('id 'TM_StringTitleID' dis='TMGadStatus 'gt ""')
  995.     CALL topipe('id 'TM_StringShortCutID' dis='TMGadStatus 'gt ""')
  996.     CALL topipe('id 'TM_GetFileID' dis='TMGadStatus 'fn "rexx:"')
  997.     CALL topipe('id 'TM_StringArgsID' dis='TMGadStatus 'gt ""')
  998.     TM_StringNameValue    = ""
  999.     TM_StringTitleValue    = ""
  1000.     TM_StringShortcutValue    = ""
  1001.     TM_StringCommandValue    = "rexx:"
  1002.     TM_StringArgsValue    = ""
  1003. RETURN
  1004.  
  1005. WriteHKStem:
  1006.     HK_Name.Node_ID = HK_name
  1007.     HK_Key.Node_ID = HK_Key
  1008.     call parseHKArgs()            /* write command and args */
  1009.  
  1010.     HK_counter = HK_counter + 1
  1011.     HK_Entries = HK_Entries Node_ID        /* add GID to HK_entries */
  1012. RETURN
  1013.  
  1014. HKClearStrings:
  1015.     CALL topipe('id 'HK_StringNameID 'dis='HKGadStatus 'gt ""')
  1016.     CALL topipe('id 'HK_StringHotKeyID 'dis='HKGadStatus 'gt ""')
  1017.     CALL topipe('id 'HK_GetFileID 'dis='HKGadStatus 'fn "rexx:"')
  1018.     CALL topipe('id 'HK_StringArgsID 'dis='HKGadStatus 'gt ""')
  1019.     call topipe('id 'HK_GetFileID' dis='HKGadStatus)
  1020.  
  1021.     HK_StringNameValue    = ""
  1022.     HK_StringHotKeyValue    = ""
  1023.     HK_StringCommandValue    = "rexx:"
  1024.     HK_StringArgsValue    = ""
  1025.  
  1026. RETURN
  1027.  
  1028. _Save:
  1029. IF TM_counter = 0 & HK_counter = 0 THEN RETURN
  1030. CALL OPEN(file,scriptname,write)
  1031. CALL WRITELN(file,"/*"localestring(MSG_Created)" T.H.E.*/"||NL||"ADDRESS WORKBENCH")
  1032.  
  1033. IF HK_counter >0 THEN DO
  1034.     DO i = 1 to WORDS(HK_entries)
  1035.         val = WORD(HK_entries,i)
  1036.         IF HK_Args.val ~= "" THEN commandArgs = HK_Command.val HK_Args.val
  1037.                         ELSE commandArgs = HK_Command.val||HK_Args.val
  1038.         commandArgs = STRIP(commandArgs,B)
  1039.         CALL WRITELN(file,KEYBOARD ADD NAME '''"'||HK_Name.val||'"''' KEY '''"'||HK_Key.val||'"''' CMD '"'||commandArgs||'"')
  1040.     END
  1041. END
  1042.  
  1043. IF TM_counter >0 THEN DO
  1044. CALL WRITELN(file,"")
  1045.     DO i = 1 to WORDS(tm_entries)
  1046.         val = WORD(tm_entries,i)
  1047.         IF TM_Args.val ~= "" THEN commandArgs = TM_Command.val TM_Args.val
  1048.                         ELSE commandArgs = TM_Command.val||TM_Args.val
  1049.         commandArgs = STRIP(commandArgs,B)
  1050.  
  1051.     IF TM_Shortcut.val = "" THEN CALL WRITELN(file,MENU ADD NAME '''"'||TM_name.val||'"''' TITLE '''"'||TM_title.val||'"''' CMD '"'||commandArgs||'"')
  1052.                     ELSE CALL WRITELN(file,MENU ADD NAME '''"'||TM_name.val||'"''' TITLE '''"'||TM_title.val||'"''' SHORTCUT '"'||TM_Shortcut.val||'"' CMD '"'||commandArgs||'"')
  1053.         END
  1054. END
  1055. CALL CLOSE(file)
  1056. RETURN
  1057.  
  1058. _RemoveMenuHotkeys:
  1059.     GETATTR KEYCOMMANDS.COUNT
  1060.     clearkey = result
  1061.     DO i = clearKey - 1 to 0 BY - 1
  1062.         GETATTR KEYCOMMANDS.i.NAME
  1063.         name1 = result
  1064.         KEYBOARD NAME '"'||name1||'"' REMOVE
  1065.     END
  1066.  
  1067.     GETATTR MENUCOMMANDS.COUNT
  1068.     clearMenu = result
  1069.     DO i = clearMenu - 1 to 0 BY - 1
  1070.         GETATTR MENUCOMMANDS.i.NAME
  1071.         name1 = result
  1072.         MENU NAME '"'||name1||'"' REMOVE
  1073.     END
  1074. RETURN
  1075.  
  1076. _UpdateTMStrings:
  1077. PARSE ARG val
  1078. /* update gui for current node */
  1079. IF FIND(tm_entries,val) = 0 THEN RETURN
  1080. call topipe('id 'TM_StringNameID' dis='TMGadStatus 'gt "'TM_name.val'" ref')
  1081. call topipe('id 'TM_StringTitleID' dis='TMGadStatus 'gt "'TM_title.val'" ref')
  1082. call topipe('id 'TM_StringShortcutID' dis='TMGadStatus 'gt "'TM_shortcut.val'" ref')
  1083. call topipe('id 'TM_GetFileID' dis='TMGadStatus 'fn "'TM_command.val'" ref')
  1084. call topipe('id 'TM_StringArgsID' dis='TMGadStatus 'gt "'TM_Args.val'" ref')
  1085. RETURN
  1086.  
  1087. _UpdateHKStrings:
  1088. PARSE ARG val
  1089. /* update gui for current node */
  1090. IF FIND(hk_entries,val) = 0 THEN RETURN
  1091. call topipe('id 'HK_StringNameID' dis='HKGadStatus 'gt "'HK_name.val'" ref')
  1092. call topipe('id 'HK_StringHotKeyID' dis='HKGadStatus 'gt "'HK_Key.val'" ref')
  1093. call topipe('id 'HK_GetFileID' dis='HKGadStatus 'fn "'HK_command.val'" ref')
  1094. call topipe('id 'HK_StringArgsID' dis='HKGadStatus 'gt "'HK_Args.val'" ref')
  1095. RETURN
  1096.  
  1097. SwapTM:
  1098. TM_name.bak1 = TM_Name.prevEntry
  1099. TM_name.bak2 = TM_Name.TM_currentnode
  1100. TM_Title.bak1 = TM_Title.prevEntry 
  1101. TM_Title.bak2 = TM_Title.TM_currentnode 
  1102. TM_ShortCut.bak1 = TM_ShortCut.prevEntry
  1103. TM_ShortCut.bak2 = TM_ShortCut.TM_currentnode
  1104. TM_Command.bak1 = TM_Command.prevEntry
  1105. TM_Command.bak2 = TM_Command.TM_currentnode
  1106. TM_Args.bak1 = TM_Args.prevEntry
  1107. TM_Args.bak2 = TM_Args.TM_currentnode
  1108.  
  1109. TM_Name.prevEntry        = TM_name.bak2
  1110. TM_Name.TM_currentnode        = TM_name.bak1
  1111. TM_Title.prevEntry        = TM_Title.bak2
  1112. TM_Title.TM_currentnode        = TM_Title.bak1
  1113. TM_ShortCut.prevEntry        = TM_ShortCut.bak2
  1114. TM_ShortCut.TM_currentnode    = TM_ShortCut.bak1
  1115. TM_Command.prevEntry        = TM_Command.bak2
  1116. TM_Command.TM_currentnode    = TM_Command.bak1
  1117. TM_Args.prevEntry        = TM_Args.bak2
  1118. TM_Args.TM_currentnode        = TM_Args.bak1
  1119.  
  1120. call topipe2('id 'TM_ListViewID' list 0')
  1121. IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
  1122.                 ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
  1123. call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
  1124.  
  1125. IF TM_Args.prevEntry    ~= "" THEN commandArgs = TM_Command.prevEntry TM_Args.prevEntry
  1126.                 ELSE commandArgs = TM_Command.prevEntry||TM_Args.prevEntry
  1127. call topipe('id 'prevEntry' gt "'TM_Name.prevEntry'|'TM_title.prevEntry'|'TM_ShortCut.prevEntry'|'commandArgs'"')
  1128. call topipe2('id 'TM_ListViewID' list 1 page' pageid)
  1129. RETURN
  1130.  
  1131. ShellResult:
  1132. PARSE ARG ShellCmd
  1133. cmdid='req'pragma('id')
  1134. address command 'rxset' cmdid Shellcmd
  1135. from_Shell=getclip(cmdid)
  1136. call setclip(cmdid,'')
  1137. RETURN(from_Shell)
  1138.  
  1139. parseTMArgs:
  1140. IF LEFT(mt_command,1) = "'" | LEFT(mt_command,1) = '"' THEN DO
  1141.         TM_command.Node_ID=""
  1142.         TM_Args.Node_ID   = mt_command
  1143. RETURN
  1144. END
  1145.  
  1146.     IF WORDS(mt_command) >1 THEN DO            /* more than one word? */
  1147.         firstchar= INDEX(mt_command,":")
  1148.         IF firstchar = 0 THEN firstchar = 1
  1149.         firstArg = INDEX(mt_command," ",firstchar)
  1150.         IF firstArg = 0 THEN firstArg = 1
  1151.             TM_command.Node_ID= SUBSTR(mt_command,1,firstArg-1)
  1152.             TM_Args.Node_ID   = RIGHT(mt_command,LENGTH(mt_command)-firstArg)
  1153.     END
  1154.     ELSE DO
  1155.         TM_command.Node_ID=mt_command
  1156.         TM_Args.Node_ID   = ""
  1157.     END
  1158. RETURN
  1159.  
  1160. parseHKArgs:
  1161. IF LEFT(hk_command,1) = "'" | LEFT(hk_command,1) = '"' THEN DO
  1162.         HK_command.Node_ID=""
  1163.         HK_Args.Node_ID   = hk_command
  1164. RETURN
  1165. END
  1166.     IF WORDS(hk_command) >1 THEN DO            /* more than one word? */
  1167.         firstchar= INDEX(hk_command,":")
  1168.         IF firstchar = 0 THEN firstchar = 1
  1169.         firstArg = INDEX(hk_command," ",firstchar)
  1170.         IF firstArg = 0 THEN firstArg = 1
  1171.             HK_command.Node_ID= SUBSTR(hk_command,1,firstArg-1)
  1172.             HK_Args.Node_ID   = RIGHT(hk_command,LENGTH(hk_command)-firstArg)
  1173.     END
  1174.     ELSE DO
  1175.         HK_command.Node_ID=hk_command
  1176.         HK_Args.Node_ID   = ""
  1177.     END
  1178. RETURN
  1179.  
  1180. _DisableTMGads:
  1181. PARSE ARG TMGadStatus
  1182.     IF TMGadStatus.bak = TMGadStatus THEN RETURN
  1183.     call topipe('id 'TM_RemoveID' dis='TMGadStatus 'ref')
  1184.     call topipe('id 'TM_CloneID ' dis='TMGadStatus 'ref')
  1185.     call topipe('id 'TM_UpID' dis='TMGadStatus 'ref')
  1186.     call topipe('id 'TM_DownID' dis='TMGadStatus 'ref')
  1187.     TMGadStatus.bak = TMGadStatus
  1188. RETURN
  1189.  
  1190. _DisableHKGads:
  1191. PARSE ARG HKGadStatus
  1192.     IF HKGadStatus.bak = HKGadStatus THEN RETURN
  1193.     call topipe('id 'HK_RemoveID 'dis='HKGadStatus 'ref')
  1194.     call topipe('id 'HK_CancelBoxID' dis='HKGadStatus 'ref')
  1195.     call topipe('id 'HK_ChooserID' dis='HKGadStatus 'ref')
  1196.     call topipe('id 'HK_CloneID' dis='HKGadStatus 'ref')
  1197.     HKGadStatus.bak = HKGadStatus
  1198. RETURN
  1199.  
  1200. BuildInLanguage:
  1201. /*
  1202. ** $VER: THE.strings 1.0 (14.10.99) ©1999 by Nils Görs
  1203. */
  1204. MSG_MAIN_ToolsMenu = 0
  1205. MSG_MAIN_HotkeyMenu = 1
  1206. MSG_TM_ToolsMenu = 2
  1207. MSG_HK_Hotkey = 3
  1208. MSG_TM_LV_Title = 4
  1209. MSG_HK_LV_Title = 5
  1210. MSG_Button_Add = 6
  1211. MSG_Button_Remove = 7
  1212. MSG_Button_Up = 8
  1213. MSG_Button_Down = 9
  1214. MSG_Button_Save = 10
  1215. MSG_Button_Use = 11
  1216. MSG_Button_Cancel = 12
  1217. MSG_String_Name = 13
  1218. MSG_String_Command = 14
  1219. MSG_String_Title = 15
  1220. MSG_String_ShortCut = 16
  1221. MSG_String_HotKey = 17
  1222. MSG_New_Name = 18
  1223. MSG_New_Title = 19
  1224. MSG_New_Hotkey = 20
  1225. MSG_TitleName = 21
  1226. MSG_Created = 22
  1227. MSG_MenuT_Project = 23
  1228. MSG_Menu_About = 24
  1229. MSG_Menu_Quit = 25
  1230. MSG_Request_Quit = 26
  1231. MSG_Request_YES = 27
  1232. MSG_String_Argument = 28
  1233. MSG_MenuT_Edit = 29
  1234. MSG_Menu_Remove = 30
  1235. MSG_Menu_LastSaved = 31
  1236. MSG_Button_Clone = 32
  1237. MSG_TooManyEntries = 33
  1238.  
  1239. strings.0 = "_Tools Menu"
  1240. strings.1 = "_Hotkey Menu"
  1241. strings.2 = "Tools Menu"
  1242. strings.3 = "Hotkeys"
  1243. strings.4 = "Name|Title|SC|Command"
  1244. strings.5 = "Name|Key|Command"
  1245. strings.6 = "_Add"
  1246. strings.7 = "_Remove"
  1247. strings.8 = "U_p"
  1248. strings.9 = "_Down"
  1249. strings.10= "_Save"
  1250. strings.11= "_Use"
  1251. strings.12= "_Cancel"
  1252. strings.13= "_Name:"
  1253. strings.14= "Co_mmand:"
  1254. strings.15= "T_itle:"
  1255. strings.16= "Sh_ortCut:"
  1256. strings.17= "_Key:"
  1257. strings.18= "Edit Name"
  1258. strings.19= "Edit Title"
  1259. strings.20= "select Hotkey"
  1260. strings.21= "Workbench Tools-Menu and Hotkey Editor"
  1261. strings.22= "Created with"
  1262. strings.23= "Project"
  1263. strings.24= "@?About"
  1264. strings.25= "@QQuit"
  1265. strings.26= "Are you sure to quit?"
  1266. strings.27= "Yes|No"
  1267. strings.28= "Ar_guments:"
  1268. strings.29= "Edit"
  1269. strings.30= "@RRemove All"
  1270. strings.31= "@LLast Saved"
  1271. strings.32= "Dup_lication"
  1272. strings.33= "Sorry, only 63 menu items will fit into the Tools menu."
  1273. RETURN
  1274.