LIBRARY rexxgui, rxconsole
guierr = "ERROR"
guiheading = 1
guicreatewindow('NORMAL')
again:
DO FOREVER
guigetmsg()
CATCH SYNTAX
CONDITION()
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_initdialog:
guigetctlplacement(guiwindow, , , "width", "height")
guigetctlplacement('File', "SayX", "SayY", "SayWidth", "SayHeight")
sayy = sayy + sayheight+5
sayx=sayx+1
height = (height-34- sayy)%2
concreate('x1', guiwindow, "CHILD | NODEFAULT",4, sayy+20, width-7, height-25)
consetcolor(x1, "BACK", "White")
consetcolor(x1, "Text", 1)
consetfont(x1, "Courier New", 16,)
concreate('x2', guiwindow, "CHILD | NODEFAULT",4, sayy+height+20, width-7, height-25)
consetcolor(x2, "BACK", "White")
consetcolor(x2, "Text", 1)
consetfont(x2, "Courier New", 16,)
RETURN ""
wm_click_file:
file='*.rex'
ERROR = guifile('File', , 'Select REX To Scan')
IF file='' | file='*.rex' THEN RETURN
sfile=file
guisetctlvalue("SFILE")
CALL init
RETURN
wm_click_run:
guigetctlvalue("SFILE")
IF sfile='' THEN RETURN
IF POS('.',sfile)=0 THEN sfile=sfile||'.rex'
guigetctlvalue("VPROC")
IF vproc=1 THEN NOP
ELSE vrpoc=0
ovarlen=20
IF vproc=0 THEN oproclen=0
ELSE oproclen=15
split=77-ovarlen-oproclen
IF LOADTEXT('code.',sfile,'LT')=0 THEN RETURN
CALL init
CALL scanvar
CALL scanproc
CALL sortv
CALL outproc
CALL outvar
RETURN
outproc:
split2=split-8
IF procs.0=0 THEN consay(x1,'None')
ELSE DO i=1 TO procs.0
len=linesplit(procref.i,split2)
vreflin=STRIP(SUBSTR(procref.i,1,len))
vrefn=STRIP(SUBSTR(procref.i,len+1))
IF proctype.i='P' THEN ptype=' '
ELSE ptype='+'
consay(x1,RIGHT(i,3) LEFT(procs.i,ovarlen) RIGHT(procdef.i,4)ptype ' ' vreflin)
DO WHILE vrefn \= ''
len=linesplit(vrefn,split2)
vreflin=STRIP(SUBSTR(vrefn,1,len))
consay(x1,COPIES(' ',ovarlen+2+10) vreflin)
vrefn=STRIP(SUBSTR(vrefn,len+1))
END
END
RETURN
outvar:
DO i=1 TO variable.0
len=linesplit(varref.i,split)
vreflin=STRIP(SUBSTR(varref.i,1,len))
vrefn=STRIP(SUBSTR(varref.i,len+1))
IF LENGTH(variable.i)<ovarlen+oproclen THEN consay(x2,RIGHT(i,3) LEFT(variable.i,ovarlen+oproclen) vreflin)
ELSE consay(x2,RIGHT(i,3) variable.i vreflin)
DO WHILE vrefn \= ''
len=linesplit(vrefn,split)
vreflin=STRIP(SUBSTR(vrefn,1,len))
consay(x2,COPIES(' ',ovarlen+oproclen+4) vreflin)
vrefn=STRIP(SUBSTR(vrefn,len+1))
END
END
RETURN
sortv:
OPTIONS "SORT"
SORT = "varref."
SORT variable. a
OPTIONS "SORT"
SORT = "procref. procdef."
SORT procs. a
RETURN
scanvar:
DO i=1 TO code.0
code.i=TRANSLATE(code.i)
line=CHANGESTR('=',code.i,' = ')
line=CHANGESTR(':',line,': ')
fword=WORD(line,1)
IF LENGTH(fword)<2 THEN fword='????'
IF POS('PROCEDURE',line)>0 THEN current_proc=proc(line,current_proc,i)
ELSE IF SUBSTR(fword,LENGTH(fword),1)=':' THEN CALL label(fword,i)
PARSE VALUE line WITH varx eq rem
IF eq = '=' THEN CALL addvar(varx,i,,current_proc,vproc)
ELSE IF varx='PARSE' THEN CALL PARSE
END
RETURN
scanproc:
DO i=1 TO code.0
DO j=1 TO procs.0
IF POS(procs.j'(',code.i)>0 THEN procref.j=procref.j||i||' '
END
END
RETURN
parse:
line=STRIP(TRANSLATE(line,,"',;/."'"'))
IF eq='ARG' THEN DO
argx=POS('ARG',line)
IF argx>0 THEN line=SUBSTR(line,argx)
parsem='+'
END
ELSE IF eq='VALUE' THEN DO
withx=POS('WITH',line)
IF withx>0 THEN line=SUBSTR(line,withx)
parsem='*'
END
PARSE VALUE line WITH withx v.1 v.2 v.3 v.3 v.4 v.5 v.6 v.7 v.8 v.9 v.10 v.11 v.12 v.13 v.14 v.15
DO j=1 TO 15
CALL addvar(v.j,i,parsem,current_proc,vproc)
END
RETURN
proc: PROCEDURE EXPOSE procs. proctype. procref. procdef.
PARSE ARG line,cproc,linei
ip=POS('PROCEDURE',line)
IF ip<2 THEN RETURN cproc
proc=STRIP(SUBSTR(line,1,ip-1))
IF WORDS(proc) \= 1 THEN RETURN cproc
IF SUBSTR(proc,LENGTH(proc),1) \= ':' THEN RETURN cproc
proc=SUBSTR(proc,1,LENGTH(proc)-1)
si=procs.0+1
procs.0=si
procs.si=proc
procdef.si=linei
procref.si=''
proctype.si='P'
RETURN proc
label: PROCEDURE EXPOSE procs. proctype. procref. procdef.
PARSE ARG flabel,linei
flabel=STRIP(TRANSLATE(flabel,,':'))
IF flabel='' THEN RETURN
si=procs.0+1
procs.0=si
procs.si=flabel
procdef.si=linei
procref.si=''
proctype.si='L'
RETURN
addvar: PROCEDURE EXPOSE variable. varref.
PARSE ARG varname,line,settype,cproc,showproc
IF varname='' THEN RETURN
fstr=STRIP(TRANSLATE(SUBSTR(varname,1,1),,'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
IF fstr\='' THEN RETURN
IF showproc=1 THEN varname=varname||'('||cproc||')'
si=search(variable.,varname,,,'M','UPPER')
IF si<1 THEN DO
si=variable.0+1
varref.si=''
variable.0=si
END
variable.si=varname
varref.si=varref.si||line||settype||' '
RETURN
linesplit: PROCEDURE
PARSE ARG string, offset
IF SUBSTR(string,offset,1)=' ' THEN RETURN offset
sstr=SUBSTR(string,1,offset)
wrd=WORDS(sstr)
offset=WORDINDEX(sstr,wrd)-1
RETURN offset
search:procedure
USE ARG stemin.,sstr,from,tohi,match,case
IF EXISTS('stemin.0')=0 THEN RETURN -1
hi=stemin.0
IF sstr='SQL_KEY_COLNAME' THEN DO
NOP
END
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 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
init:
DROP code variable. procs. varref. procdef. procref.
conclear(x1)
conclear(x2)
variable.0=0
procs.0=0
vari=0
current_proc='MAIN'
RETURN |
|