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
END
CATCH SYNTAX
CONDITION()
SIGNAL again
CATCH HALT
FINALLY
terminate:
guidestroywindow()
END
RETURN
current_files:
regdir=VALUE('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\RxLaunch.exe\Path', ,"WIN32")
ERROR = guisendmsg("RegFiles", "DIR", , regdir||"*.rex")
RETURN
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
wm_dblclk_recent:
guigetctlvalue("Recent")
CALL open(recent)
SIGNAL terminate
RETURN
wm_dblclk_regfiles:
guigetctlvalue("Regfiles")
CALL open(regfiles)
SIGNAL terminate
RETURN
open:
PARSE ARG file
CALL archive(file)
CALL addtorecent(file)
editopendoc(file,)
RETURN
wm_click_other:
file='*.rex'
ERROR = guifile('File', , 'Select REX To Open')
IF file='' | file='*.rex' THEN RETURN
CALL open(file)
SIGNAL terminate
RETURN
wm_click_clear:
old.0=0
guiaddctltext("Recent", "Old")
LOADTEXT('old','RecentFiles.txt','S')
RETURN
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
wm_click_cancel:
SIGNAL terminate
RETURN
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
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
archive:procedure
PARSE ARG file,maxversion,VERSION
CALL arcinit
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
|
|