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

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

  
 
/*
GUIBEGIN

WINDOW , 26, 33, 373, 204, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Open REXX File
	FONT 8, 400, MS Shell Dlg
	MENU
	LIST 7, 27, 168, 154, NOTIFY|MULTI|BORDER|VSCROLL|TABSTOP, STATICEDGE, Recent
	LIST 187, 27, 168, 154, NOTIFY|MULTI|BORDER|VSCROLL|TABSTOP, STATICEDGE, RegFiles
	PUSH 319, 4, 40, 14, TABSTOP, , other, , Other File
	PUSH 5, 183, 40, 14, TABSTOP, , clear, , Clear
	PUSH 65, 183, 40, 14, TABSTOP, , Reduce, , Reduce
	PUSH 320, 183, 40, 14, TABSTOP, , Open, , Open
	PUSH 260, 183, 40, 14, TABSTOP, , Cancel, , Cancel
	GROUP 183, 17, 176, 161, , , regbox, , Reginald Directory
	GROUP 3, 17, 176, 161, , , , , Recent Files
	METAFILE 364, 58, 9, 87, , , left
DEND

MENU
	HEADING Options, Options
		ITEM Source Directory, SD
		ITEM Backup Directory, BD
		ITEM Reset Source Dir to Default, Sres
		ITEM Reset Backup Dir, bres
	<
	HEADING ?, HelpM
		ITEM Help, Help
	<
DEND
GUIEND
*/
LIBRARY rexxgui
guierr = "ERROR"
guiheading = 1

guicreatewindow('NORMAL')
CALL init
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:
ERROR = guiremovectltext("RegFiles")
ERROR = guisendmsg("RegFiles", "DIR", , regdir||"*.rex")
ERROR = guiaddctltext("Regbox", regdir)
RETURN 
/* ------------------------------------------------------------------------------------
 * Build List of recently opened Files
 * ------------------------------------------------------------------------------------
 */
recent_files:
LOADTEXT('old','RecentFiles.txt','B')
j=0
recfile.0=0
DO i=old.0 TO 1 BY -1
   IF old.i='' THEN ITERATE
   PARSE VALUE old.i WITH rfile ';' rdir
   rfile=STRIP(rfile)
   rdir=STRIP(rdir)
   IF search(recfile.,rfile,,,'M','UPPER')>0 THEN DO
      old.i=''
      ITERATE
   END
   j=j+1
   recfile.j=rfile
   recdir.j=rdir
   recfile.0=j
END
guiaddctltext("Recent", "Recfile")
LOADTEXT('old','RecentFiles.txt','SB')
RETURN
/* ------------------------------------------------------------------------------------
 * Init Procedure 
 * ------------------------------------------------------------------------------------
 */
init:
initdir=DIRECTORY()
regdir=regread('SourceDirectory') 
IF regdir='' THEN regdir=DIRECTORY()||'\'
bckdir=regread('BackupDirectory') 
IF bckdir='' THEN DO 
   ERROR=guifile('bckdir','BROWSE|ENTRY|NEWFOLDER' , 'Intial Set up of Backup Directory',,regdir)
   IF bckdir='' THEN EXIT 8
   IF SUBSTR(bckdir,LENGTH(bckdir),1) \='\' THEN bckdir=bckdir||'\'
   regwrite('BackupDirectory',bckdir) 
END  
RETURN
/* ------------------------------------------------------------------------------------
 * File selected (Recent List)
 * ------------------------------------------------------------------------------------
 */
wm_dblclk_recent:
guigetctlvalue("Recent")
IF recent.0='' THEN RETURN 
DO si=1 TO recent.0
   ri=search(recfile.,recent.si,,,'M','UPPER')
   IF ri<1 THEN ITERATE
   CALL open(recdir.ri||recfile.ri)
END
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * File selected (Reginald Files List)
 * ------------------------------------------------------------------------------------
 */
wm_dblclk_regfiles:
guigetctlvalue("Regfiles")
IF regfiles.0='' THEN RETURN 
DO si=1 TO regfiles.0
   CALL open(regfiles.si)
END
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * Open selected File in Editor
 * ------------------------------------------------------------------------------------
 */
open:
PARSE ARG ofile
IF POS('\',ofile)=0 THEN ofile=regdir||ofile
CALL archive(ofile,bckdir)
CALL addtorecent(ofile) 
editopendoc(ofile,) 
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','SB')
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:
rc=guigetctlvalue("Regfiles")
IF rc='' THEN DO si=1 TO regfiles.0
   CALL open(regfiles.si)
END
rc=guigetctlvalue("Recent")
IF rc='' THEN DO si=1 TO recent.0
   CALL open(recent.si)
END 
SIGNAL terminate
RETURN
/* ------------------------------------------------------------------------------------
 * Add opened File to Recent List and save it into Reginald directory
 * ------------------------------------------------------------------------------------
 */
addtorecent:
PARSE ARG sfile
rc=PATH('Ffile', sfile)
file=ffile.2||ffile.3
spath=ffile.0||ffile.1
sr=search(old.,file ';',,,'M','UPPER')
IF sr>0 THEN old.sr='' 
rmax=old.0+1
old.rmax=file ';' spath
old.0=rmax
LOADTEXT('old','RecentFiles.txt','SB')
RETURN
/* ------------------------------------------------------------------------------------
 * Write Registry Entry
 * ------------------------------------------------------------------------------------
 */
regwrite: PROCEDURE
PARSE ARG key,regval
ERROR=VALUE("OpenRex\", , "WIN32") 
previous=VALUE("OpenRex\"||key, regval,"WIN32")
RETURN 0
/* ------------------------------------------------------------------------------------
 * Read Registry Entry
 * ------------------------------------------------------------------------------------
 */ 
regread: PROCEDURE
PARSE ARG key
RETURN VALUE("OpenRex\"||key, ,"WIN32")
/* ------------------------------------------------------------------------------------
 * Delete Registry Entry
 * ------------------------------------------------------------------------------------
 */ 
regdel: PROCEDURE
PARSE ARG key
RETURN VALUE('',"OpenRex\"||key,"WIN32")
/* ------------------------------------------------------------------------------------
 * Menu: Change Source Direcory 
 * ------------------------------------------------------------------------------------
 */
sd:
ERROR = guifile('File','BROWSE|ENTRY|NEWFOLDER' , 'Change Source Directory (now 'regdir')',,regdir)
IF EXISTS('file')=0 THEN RETURN
IF file \='' THEN DO 
   regdir=file
   IF SUBSTR(regdir,LENGTH(regdir),1) \='\' THEN regdir=regdir||'\'
   regwrite('SourceDirectory',regdir) 
   CALL current_files
END 
RETURN 
/* ------------------------------------------------------------------------------------
 * Menu: Change Backup Direcory 
 * ------------------------------------------------------------------------------------
 */
bd:
ERROR = guifile('File','BROWSE|ENTRY|NEWFOLDER' , 'Change Backup Directory (now 'bckdir')',,regdir)
IF EXISTS('file')=0 THEN RETURN
IF file \='' THEN DO 
   bckdir=file
   IF SUBSTR(bckdir,LENGTH(bckdir),1) \='\' THEN bckdir=bckdir||'\'
   regwrite('BackupDirectory',bckdir) 
END
RETURN 
/* ------------------------------------------------------------------------------------
 * Menu: Set Source Directory to Default
 * ------------------------------------------------------------------------------------
 */
sres:
regdel('SourceDirectory') 
CALL init
CALL current_files
RETURN
/* ------------------------------------------------------------------------------------
 * Menu: Set Source Directory to Default
 * ------------------------------------------------------------------------------------
 */
bres:
regdel('BackupDirectory') 
RETURN 
/* ------------------------------------------------------------------------------------
 * Menu: Help
 * ------------------------------------------------------------------------------------
 */
help:
guisay('Help not yet defined')
RETURN 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/*** --------------------------------------------------------------------------- */
/*** Auto Loaded Modules, source changes should be done in the original modules  */
/*** --------------------------------------------------------------------------- */  /*$$AUTOLOAD ALL */
search:procedure
USE ARG stemin.,sstr,from,tohi,match,case
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
up=TRANSLATE(case)
IF up='NO' | SUBSTR(up,1,1)='U' THEN OPTIONS 'CASELESS' 
   ELSE OPTIONS 'NOCASELESS' 
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
archive:procedure
PARSE ARG file,backupdir,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)
newfile=ffile.2||ffile.3||vext
IF backupdir \='' THEN newfile=backupdir||newfile
IF STATE(newfile)=0 THEN CALL archive(newfile,backupdir,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
IF backupdir \= '' THEN IF SUBSTR(backupdir,LENGTH(backupdir),1) \='\' THEN backupdir=backupdir||'\'
RETURN 
                                /*$$AUTOLOAD END ALL */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of (Auto-) Loaded Modules                                                                          */
/*** ------------------------------------------------------------------------------------------------------- */
/*** RexHeader.REX           C:\Programme\Reginald\SysProc\         INCLUDE         16BT 23/01/2006 13:01:58 */
/*** SEARCH.REX              C:\Programme\Reginald\SysProc\         AUTOLOAD         1KB 05/09/2007 09:09:57 */
/*** ARCHIVE.REX             C:\Programme\Reginald\                 AUTOLOAD         1KB 11/09/2007 15:09:51 */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of Procedures      Defined  Used in Line   Suffix "+" Label, none Procedure                        */
/*** ------------------------------------------------------------------------------------------------------- */
/***   1 ADDTORECENT           213+   148                                                                    */
/***   2 AGAIN                  41+                                                                          */
/***   3 ARCHIVE               342    147 352                                                                */
/***   4 ARCINIT               357+                                                                          */
/***   5 BD                    266+                                                                          */
/***   6 BRES                  288+                                                                          */
/***   7 CURRENT_FILES          68+                                                                          */
/***   8 HELP                  295+                                                                          */
/***   9 INIT                  102+                                                                          */
/***  10 OPEN                  144+   124 136 159 201 205                                                    */
/***  11 RECENT_FILES           77+                                                                          */
/***  12 REGDEL                245    280 289                                                                */
/***  13 REGREAD               238    104 106                                                                */
/***  14 REGWRITE              229    111 258 272                                                            */
/***  15 SD                    252+                                                                          */
/***  16 SEARCH                321    86 122 218                                                             */
/***  17 SRES                  279+                                                                          */
/***  18 TERMINATE              60+                                                                          */
/***  19 WM_CLICK_CANCEL       191+                                                                          */
/***  20 WM_CLICK_CLEAR        166+                                                                          */
/***  21 WM_CLICK_OPEN         198+                                                                          */
/***  22 WM_CLICK_OTHER        155+                                                                          */
/***  23 WM_CLICK_REDUCE       175+                                                                          */
/***  24 WM_DBLCLK_RECENT      118+                                                                          */
/***  25 WM_DBLCLK_REGFILES    132+                                                                          */
/*** ------------------------------------------------------------------------------------------------------- */
/*** XREF of Variables              Modified in Line   Suffix "+" Parse Arg, "*" Parse Variable, none SET    */
/*** ------------------------------------------------------------------------------------------------------- */
/***   1 BACKUPDIR                           343+                                                            */
/***   2 BCKDIR                              106 270                                                         */
/***   3 ERROR                               69 70 71 108 157 231 253 267                                    */
/***   4 FILE                                156 216 343+                                                    */
/***   5 GUIERR                              34                                                              */
/***   6 GUIHEADING                          35                                                              */
/***   7 HI                                  323                                                             */
/***   8 INITDIR                             103                                                             */
/***   9 J                                   79 90 177 179                                                   */
/***  10 KEY                                 230+ 239+ 246+                                                  */
/***  11 LPOS                                368                                                             */
/***  12 NEWFILE                             350                                                             */
/***  13 OFILE                               145+                                                            */
/***  14 OLD.0                               167 183 222                                                     */
/***  15 OLD.I                               87                                                              */
/***  16 OLD.J                               180                                                             */
/***  17 OLD.RMAX                            221                                                             */
/***  18 PREF                                361 365                                                         */
/***  19 PREVIOUS                            232                                                             */
/***  20 RC                                  199 203 215 359                                                 */
/***  21 RDIR                                83* 85                                                          */
/***  22 RECDIR.J                            92                                                              */
/***  23 RECENT.0                            182                                                             */
/***  24 RECFILE.0                           80 93                                                           */
/***  25 RECFILE.J                           91                                                              */
/***  26 REGDIR                              104 256                                                         */
/***  27 REGVAL                              230+                                                            */
/***  28 RFILE                               83* 84                                                          */
/***  29 RI                                  122                                                             */
/***  30 RMAX                                176 220                                                         */
/***  31 SFILE                               214+                                                            */
/***  32 SPATH                               217                                                             */
/***  33 SR                                  218                                                             */
/***  34 UP                                  332                                                             */
/***  35 VERSION                             343+ 362 370                                                    */
/***  36 VEXT                                349                                                             */
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-10-12  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2007-09-12 01:53:02