Guidance
指路人
g.yi.org
Upload / Forum Attachment / Reginald Rexx Programming Language Compiler User Forum Attachments and Pictures / 11785-OpenRex.rex

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

  
/*
GUIBEGIN

WINDOW , 0, 0, 363, 204, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Open REXX File
	FONT 8, 400, MS Shell Dlg
	LIST 6, 27, 170, 154, NOTIFY|BORDER|VSCROLL|TABSTOP, , Recent
	LIST 184, 26, 170, 154, NOTIFY|BORDER|VSCROLL|TABSTOP, , RegFiles
	TEXT 7, 12, 67, 8, GROUP, , , , Recent Files
	TEXT 184, 12, 80, 8, GROUP, , , , Reginald Directory
	PUSH 312, 6, 40, 14, TABSTOP, , other, , Other File
	PUSH 7, 178, 40, 14, TABSTOP, , clear, , Clear
	PUSH 65, 178, 40, 14, TABSTOP, , Reduce, , Reduce
	PUSH 315, 178, 40, 14, TABSTOP, , Open, , Open
	PUSH 257, 178, 40, 14, TABSTOP, , Cancel, , Cancel
DEND
GUIEND
*/
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1

guicreatewindow('NORMAL')
CALL recent_files
CALL current_files
again:
DO FOREVER
	guigetmsg()
	IF EXISTS('GuiObject') == 0 THEN DO
		IF EXISTS('GuiSignal') THEN DO
		END
	END
	ELSE DO
		IF EXISTS('GuiSignal') == 0 THEN DROP (guiobject)
		ELSE SELECT guiobject
			WHEN 0 THEN NOP
			OTHERWISE
		END /* SELECT GuiObject */

	END /* Some child script signaled us */
	CATCH SYNTAX
			CONDITION()
			SIGNAL again

	CATCH HALT
	FINALLY
terminate:
		guidestroywindow()
END
RETURN
/* ------------------------------------------------------------------------------------
 * Build List of Files in Reginald Directory 
 * ------------------------------------------------------------------------------------
 */
current_files:
regdir=VALUE('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\RxLaunch.exe\Path', ,"WIN32")
ERROR = guisendmsg("RegFiles", "DIR", , regdir||"*.rex")
RETURN 
/* ------------------------------------------------------------------------------------
 * Build List of recently opened Files
 * ------------------------------------------------------------------------------------
 */
recent_files:
LOADTEXT('old','RecentFiles.txt','B')
j=0
DO i=old.0 TO 1 BY -1
   IF old.i='' THEN ITERATE
   j=j+1
   recent.j=old.i
END
recent.0=old.0
guiaddctltext("Recent", "Recent")
RETURN
/* ------------------------------------------------------------------------------------
 * File selected (Recent List)
 * ------------------------------------------------------------------------------------
 */
wm_dblclk_recent:
guigetctlvalue("Recent")
CALL open(recent)
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * File selected (Reginald Files List)
 * ------------------------------------------------------------------------------------
 */
wm_dblclk_regfiles:
guigetctlvalue("Regfiles")
CALL open(regfiles)
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * Open selected File in Editor
 * ------------------------------------------------------------------------------------
 */
open:
PARSE ARG file
CALL archive(file)
CALL addtorecent(file) 
editopendoc(file,) 
RETURN
/* ------------------------------------------------------------------------------------
 * Let user select File via standard dialog
 * ------------------------------------------------------------------------------------
 */ 
wm_click_other:
file='*.rex'
ERROR = guifile('File', , 'Select REX To Open')
IF file='' | file='*.rex' THEN RETURN
CALL open(file)
SIGNAL terminate
RETURN 
/* ------------------------------------------------------------------------------------
 * Clear the Recent File list
 * ------------------------------------------------------------------------------------
 */
wm_click_clear:
old.0=0
guiaddctltext("Recent", "Old")
LOADTEXT('old','RecentFiles.txt','S')
RETURN
/* ------------------------------------------------------------------------------------
 * REduce the Recent File list to the previous 10 entries
 * ------------------------------------------------------------------------------------
 */
wm_click_reduce:
rmax=MIN(10,recent.i)
j=rmax+1
DO i=1 TO rmax 
   j=j-1
   old.j=recent.i
END
recent.0=rmax
old.0=rmax
guiaddctltext("Recent", "Recent")
LOADTEXT('old','RecentFiles.txt','SB')
RETURN
/* ------------------------------------------------------------------------------------
 * Cancel Open 
 * ------------------------------------------------------------------------------------
 */
wm_click_cancel:
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * Open Files via OPEN Button, check both lists! 
 * ------------------------------------------------------------------------------------
 */
wm_click_open:
guigetctlvalue("Regfiles")
IF EXISTS('regfiles')=1 THEN CALL open(regfiles)
guigetctlvalue("Recent")
IF EXISTS('recent')=1 THEN CALL open(recent)
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * Add opened File to Recent List and save it into Reginald directory
 * ------------------------------------------------------------------------------------
 */
addtorecent:
PARSE ARG file
sr=search(old.,file,,,'M')
IF sr>0 THEN old.sr='' 
rmax=old.0+1
old.rmax=file
old.0=rmax
LOADTEXT('old','RecentFiles.txt','S')
RETURN
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/*** --------------------------------------------------------------------------- */
/*** Auto Loaded Modules, source changes should be done in the original modules  */
/*** --------------------------------------------------------------------------- */  /*$$AUTOLOAD ALL */
archive:procedure
PARSE ARG file,maxversion,VERSION
CALL arcinit   /* init, determine current version, etc. */
IF version>=maxversion THEN DO 
   DELETEFILE(file)
   RETURN 4
END
vext='.V'RIGHT(VERSION,2,0)
IF VERSION='00' THEN newfile=file||vext
   ELSE newfile=ffile.0||ffile.1||ffile.2||ffile.3||vext
IF STATE(newfile)=0 THEN CALL archive(newfile,maxversion,version)
IF VERSION='00' THEN rc=COPYFILE(file,newfile)
   ELSE rc=MOVEFILE(file,newfile)
IF rc \= '' THEN RETURN 8
RETURN 0
arcinit:
IF maxversion='' THEN maxversion=99
rc=PATH('Ffile', file,'V')
IF VERSION='' THEN DO
   pref=SUBSTR(ffile.3,1,1)
   VERSION=SUBSTR(ffile.3,2)
   IF pref='V' & DATATYPE(version)='NUM' THEN NOP
      ELSE VERSION='00'
   pref='V'
END 
ELSE DO
   lpos=LASTPOS('.',ffile.3)
   IF lpos>1 THEN ffile.3=SUBSTR(ffile.3,1,lpos-1)
   VERSION=version+1
END
RETURN 
 
search:procedure
PARSE ARG compound
IF WORDS(TRANSLATE(compound,,'.'))<=1 THEN USE ARG stemin.,sstr,from,tohi,match,case
ELSE SIGNAL compound
hi=stemin.0
IF DATATYPE(hi) \= 'NUM' THEN RETURN -1
IF ARG(1,'E')=0 THEN RETURN -1
IF ARG(2,'E')=0 THEN RETURN 0
IF ARG(3,'E')=0 THEN from=1 
IF ARG(4,'E')=0 THEN tohi=hi
IF ARG(5,'E')=0 THEN match=''
IF ARG(6,'E')=0 THEN case=''
IF hi=0 THEN RETURN 0
IF TRANSLATE(case)='NO' THEN SIGNAL UPPER 
IF TRANSLATE(match)='M' THEN DO i=from TO tohi
   IF sstr=stemin.i THEN RETURN i
END
ELSE DO i=from TO tohi
   IF POS(sstr,stemin.i)>0 THEN RETURN i
END
RETURN 0
upper:
sstr=TRANSLATE(sstr)
IF TRANSLATE(match)='M' THEN DO i=from TO tohi
   IF sstr=TRANSLATE(stemin.i) THEN RETURN i
END
ELSE DO i=from TO tohi
   IF POS(sstr,TRANSLATE(stemin.i))>0 THEN RETURN i
END
RETURN 0
compound:
USE ARG compound,stem.,sstr,from,tohi,match,case 
word2=POS('.',compound)+1
compx=STRIP(SUBSTR(compound,word2))
hi=VALUE('stem.'||compx||'.0')
IF DATATYPE(hi) \= 'NUM' THEN RETURN -1
IF ARG(2,'E')=0 THEN RETURN -1
IF ARG(3,'E')=0 THEN RETURN 0
IF ARG(4,'E')=0 THEN from=1 
IF ARG(5,'E')=0 THEN tohi=hi
IF hi=0 THEN RETURN 0
IF TRANSLATE(case)='NO' THEN sstr=TRANSLATE(sstr) 
DO i=from TO tohi
   line=VALUE('stem.'||compx||'.i')
   IF TRANSLATE(case)='NO' THEN line=TRANSLATE(line) 
   IF TRANSLATE(match)='M' THEN DO
      IF sstr=line THEN RETURN i
   END
   ELSE IF POS(sstr,line)>0 THEN RETURN i
END
RETURN 0                        /*$$AUTOLOAD END ALL */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of (Auto-) Loaded Modules                                                                          */
/*** ------------------------------------------------------------------------------------------------------- */
/*** ARCHIVE.REX             C:\Programme\Reginald\                 AUTOLOAD         1KB 09/09/2007 19:09:18 */
/*** SEARCH.REX              C:\Programme\Reginald\SysProc\         AUTOLOAD         3KB 12/01/2007 17:01:05 */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of Procedures      Defined  Used in Line   Suffix "+" Label, none Procedure                        */
/*** ------------------------------------------------------------------------------------------------------- */
/***   1 ADDTORECENT           161+   88 109 150                                                             */
/***   2 AGAIN                  26+                                                                          */
/***   3 ARCHIVE               193    98 203                                                                 */
/***   4 ARCINIT               208+                                                                          */
/***   5 COMPOUND              253+                                                                          */
/***   6 CURRENT_FILES          55+                                                                          */
/***   7 OPEN                   96+   79 89 151 154 168                                                      */
/***   8 RECENT_FILES           63+                                                                          */
/***   9 SEARCH                225    163                                                                    */
/***  10 TERMINATE              47+                                                                          */
/***  11 UPPER                 244+                                                                          */
/***  12 WM_CLICK_CANCEL       140+                                                                          */
/***  13 WM_CLICK_CLEAR        115+                                                                          */
/***  14 WM_CLICK_OPEN         147+                                                                          */
/***  15 WM_CLICK_OTHER        105+                                                                          */
/***  16 WM_CLICK_REDUCE       124+                                                                          */
/***  17 WM_DBLCLK_RECENT       77+                                                                          */
/***  18 WM_DBLCLK_REGFILES     86+                                                                          */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of Variables              Modified in Line   Suffix "+" Parse Arg, "*" Parse Variable, none SET    */
/*** ------------------------------------------------------------------------------------------------------- */
/***   1 COMPOUND                            226+                                                            */
/***   2 COMPX                               256                                                             */
/***   3 ERROR                               57 107                                                          */
/***   4 FILE                                97+ 106 162+ 194+                                               */
/***   5 GUIERR                              20                                                              */
/***   6 GUIHEADING                          21                                                              */
/***   7 HI                                  229 257                                                         */
/***   8 J                                   65 67 126 128                                                   */
/***   9 LINE                                266                                                             */
/***  10 LPOS                                219                                                             */
/***  11 MAXVERSION                          194+                                                            */
/***  12 OLD.0                               116 132 166                                                     */
/***  13 OLD.J                               129                                                             */
/***  14 OLD.RMAX                            165                                                             */
/***  15 PREF                                212 216                                                         */
/***  16 RC                                  210                                                             */
/***  17 RECENT.0                            70 131                                                          */
/***  18 RECENT.J                            68                                                              */
/***  19 REGDIR                              56                                                              */
/***  20 RMAX                                125 164                                                         */
/***  21 SSTR                                245                                                             */
/***  22 VERSION                             213 221                                                         */
/***  23 VEXT                                200                                                             */
/***  24 WORD2                               255                                                             */
掌柜推荐
 
 
¥860.00 ·
 
 
¥410.00 ·
 
 
¥288.00 ·
 
 
¥918.00 ·
 
 
¥288.00 ·
 
 
¥264.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2007-09-10 02:33:22