home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
MAKEREXX.ZIP
/
makerexx.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-10-13
|
10KB
|
423 lines
/* MAKEREXX */
trace off
arg arguments
call STANDARD_START arguments
arg file '((' options
file = strip(strip(file),'B','"')
i = lastpos('\',file) + 1
if i \= 0 then parse var file path =(i) file
i = lastpos('.',file)
j = i + 1
parse var file fname =(i) . =(j) ftype
call SET_USER_GV_VALUES
call SET_INI_VALUES
select
when ftype = 'XXX'
then do
call PROCESS_COPYBOOK ftype fname
end
when wordpos(ftype,gv.itype) \= 0
then do
call PROCESS_MAIN_ROUTINE ftype fname
end
when fname = 'MAKE'
then do
call PROCESS_MAKE_ROUTINE
end
when fname = 'INIT'
then do
call INIT_INI
end
when fname = 'HELP'
then do
call HELP_MESSAGE
end
Otherwise
call ERROR_MESSAGE '6 0001 Invalid paramaters.'
end
call FINISHED_MESSAGE
exit 0
PROCESS_MAKE_ROUTINE: procedure expose gv. ini.
call SysIni ini.file, 'REEXPAND', 'ALL:', 'expand.list'
do m = 1 to expand.list.0
file = expand.list.m
i = lastpos('.',file)
j = i + 1
parse var file fname =(i) . =(j) ftype
call PROCESS_MAIN_ROUTINE ftype fname
end
return 0
PROCESS_MAIN_ROUTINE: procedure expose gv. ini.
arg ftype fname
call UPDATE_INI_COPYDATA ftype fname
call BUILD_MEMBER ftype fname
return result
BUILD_MEMBER: procedure expose gv. ini.
arg ftype fname
copy.level = 0
suffix = word(gv.otype,wordpos(ftype,gv.itype))
out.file = ini.rpathcmd || fname'.'suffix
filex = fname'.'ftype
interpret 'filep = RPATH'ftype
filex = syssearchpath(filep,filex)
file.status = stream(filex,'C','OPERREAD')
if file.status \= 'READY:'
then do
call ERROR_MESSAGE '4 0001 Can not find input file',
filex'. RC='file.status
return 4
end
call SysFileDelete out.file
if result > 2
then call ERROR_MESSAGE '16 0001 Problem deleting',
file'. RC='result'.'
call EXPAND_MEMBER ftype fname
file.status = stream(filex,'C','CLOSE')
tag.a = translate(strip(stream(filex,'C','QUERY EXISTS')))
tag.b = strip(stream(filex,'C','QUERY DATETIME'))
tag.c = strip(stream(filex,'C','QUERY SIZE'))
tag.line = date() time() 'FILE DATA:' tag.b tag.c
call INI_SET tag.a'|'LAST EXPANSION'|'tag.line
call INI_SET 'REEXPAND|'fname'.'ftype"|DELETE:"
return result
EXPAND_MEMBER: procedure expose gv. ini. out.file copy.level
arg ftype fname
filex = fname'.'ftype
interpret 'filep = RPATH'ftype
filex = syssearchpath(filep,filex)
file.status = stream(filex,'C','OPERREAD')
if file.status \= 'READY:'
then do
call ERROR_MESSAGE '4 0001 Can not find input file',
file'. RC='file.status
return 4
end
tag.a = strip(stream(filex,'C','QUERY DATETIME'))
tag.b = strip(stream(filex,'C','QUERY SIZE'))
tag.c = strip(stream(filex,'C','QUERY EXISTS'))
tag.line = gv.tagpx'I'copy.level || gv.tagsx '/*' tag.a tag.b tag.c '*/'
lo.rc = lineout(out.file,tag.line)
if lo.rc > 0
then call ERROR_MESSAGE '16 0001 Problem writting',
out.file'. RC='lo.rc'.'
do forever
outline = LINEIN(filex)
if outline = '' then leave
if left(outline,7) = '++COPY '
then do
if lo.rc > 0
then call ERROR_MESSAGE '16 0001 Problem writting',
out.file'. RC='lo.rc'.'
parse var outline . copy.file '((' copy.options
copy.file = strip(copy.file)
i = lastpos('.',copy.file)
j = i + 1
parse var copy.file copy.file.name =(i) . =(j) copy.file.type
outline = gv.tagpx'F'copy.level || gv.tagsx '/*' outline '*/'
lo.rc = lineout(out.file,outline)
copy.level = copy.level + 1
call EXPAND_MEMBER copy.file.type copy.file.name
copy.level = copy.level - 1
end
else do
if copy.level > 0 | gv.base.indent = 'YES'
then outline = gv.tagpx'C'copy.level || gv.tagsx outline
lo.rc = lineout(out.file,outline)
if lo.rc > 0
then call ERROR_MESSAGE '16 0001 Problem writting',
out.file'. RC='lo.rc'.'
end
end
file.status = stream(filex,'C','CLOSE')
return 0
PROCESS_COPYBOOK: procedure expose gv. ini.
arg ftype fname
call UPDATE_INI_COPYDATA ftype fname
call SEARCH_UPDATES ftype fname
return 0
SEARCH_UPDATES: procedure expose gv. ini.
arg ftype fname
call SysIni ini.file, 'COPIES', 'ALL:', 'copy.list'
if result \= ''
then call ERROR_MESSAGE '12 0001 Error reading copy list from',
file'. RC='result'.'
if copy.list.0 = 0
then call ERROR_MESSAGE '4 0001 No copy info found in' ini.file'.'
copy.data.table. = ''
k = 0
do i = 1 to copy.list.0
call SysIni ini.file, 'COPIES', copy.list.i
parse var result copy.data.index copy.data.work
do j = 1 to copy.data.index
parse var copy.data.work copy.data.member ':' copy.data.work
if copy.data.member = '' then iterate
k = k + 1
copy.data.table.main.k = copy.list.i
copy.data.table.copy.k = copy.data.member
end
end
copy.data.table.0 = k
filex = fname'.'ftype
names.found. = ''
names.found.0 = 1
this.file = translate(filex,'?',' ')
names.found.1 = filex
prefix = 'A???'
interpret prefix||this.file '= 0'
names.found.type.1 = ftype
j = 1
do i = 1 to 100000
if i > j then leave
if wordpos(names.found.type.j,gv.itype) \= 0
then do
time.stamp = date() time()
call INI_SET 'REEXPAND|'names.found.i'|'time.stamp
leave
end
do k = 1 to copy.data.table.0
copy.file = copy.data.table.copy.k
if copy.file \= names.found.i then iterate
if copy.file = ' ' then iterate
this.file = copy.data.table.main.k
this.file = translate(this.file,'?',' ')
if symbol(prefix||this.file) = 'VAR'
then leave
interpret prefix||this.file '= 0'
j = j + 1
names.found.j = this.file
m = lastpos('.',this.file)
n = m + 1
parse var this.file fname =(m) . =(n) ftype
names.found.type.j = ftype
end
end
names.found.0 = j
return 0
UPDATE_INI_COPYDATA: procedure expose gv. ini.
arg ftype fname
filex = fname'.'ftype
interpret 'filep = RPATH'ftype
filex = syssearchpath(filep,filex)
call SysFileSearch '++COPY ', filex, lines
if result = 2
then call ERROR_MESSAGE '16 0001 Not enouth memory to process',
file'. RC='result'.'
copy.data = lines.0" "
do i = 1 to lines.0
parse var lines.i . member '((' .
copy.data = copy.data||member':'
end
call INI_SET 'COPIES|'fname'.'ftype'|'copy.data
return 0
SET_INI_VALUES: procedure expose gv. ini.
ini. = ''
ini.path = directory()
ini.file = ini.path'\MAKEREXX.INI'
call SysIni ini.file, 'PATH', 'XXX'
ini.rpathxxx = result
call SysIni ini.file, 'PATH', 'REX'
ini.rpathrex = result
call SysIni ini.file, 'PATH', 'CMD'
ini.rpathcmd = result
'@SET RPATHREX='ini.rpathrex
'@SET RPATHERX='ini.rpatherx
'@SET RPATHXXX='ini.rpathxxx
'@SET RPATHCMD='ini.rpathcmd
'@SET RPATHEPM='ini.rpathepm
return 0
SET_USER_GV_VALUES: procedure expose gv.
gv.itype = 'REX EPM'
gv.otype = 'CMD ERX'
gv.tagpx = '/*.'
gv.tagsx = '.*/'
gv.base.indent = 'YES'
return 0
INIT_INI: procedure expose gv. ini.
call SysFileDelete ini.file
if result > 2
then call ERROR_MESSAGE '16 0001 Problem deleting',
ini.file'. RC='result'.'
call INI_SET 'INIT|DATE|'date()
call INI_SET 'INIT|TIME|'time()
call INI_SET 'PATH|XXX|.;C:\MAKEREXX;C:\MAKEREXX\XXX\'
call INI_SET 'PATH|REX|.;C:\MAKEREXX;C:\MAKEREXX\REX\'
call INI_SET 'PATH|EPM|.;C:\MAKEREXX;C:\MAKEREXX\REX\'
call INI_SET 'PATH|CMD|C:\MAKEREXX\CMD\'
call INI_SET 'PATH|ERX|C:\MAKEREXX\CMD\'
return 0
/* standard ini routines */
INI_SET: procedure expose gv. ini.
arg appl '|' name '|' value
call SysIni ini.file, appl, name, value
if result \= '' then return result
return 0
/* standard routines */
STANDARD_START: procedure expose gv.
gv. = ''
drop gv.v.initcode
parse upper source gv.oper.system gv.call.type gv.cmd.file.source .
if gv.oper.system <> 'OS/2'
then call ERROR_MESSAGE '16 001 This REXX routine can only run',
'in OS/2, not' gv.oper.system'.'
parse upper version gv.oper.system.version
gv.cmd.file.drive = filespec('D',gv.cmd.file.source)
gv.cmd.file.path = filespec('P',gv.cmd.file.source)
gv.cmd.file.fullpath = gv.cmd.file.drive||gv.cmd.file.path
gv.cmd.file.name = filespec('N',gv.cmd.file.source)
parse var gv.cmd.file.name gv.cmd.name '.CMD'
gv.start.dir = directory()
call RX_LOAD
gv.os2.ver = SysOS2Ver()
arg . '((' gv.options
return 0
RX_LOAD: procedure expose gv.
if \ RxFuncQuery('SysLoadFuncs')
then return 0
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
if result \= 0 then return result
call SysLoadFuncs
return result
V_CLEANUP:
if symbol('gv.v.initcode') = 'VAR'
then call VExit
if symbol('em.rc') = 'VAR' then return
exit 9999
ERROR_MESSAGE: procedure expose gv.
arg em.rc msg
if symbol('gv.v.initcode') = 'VAR'
then call ERROR_MESSAGE_SCREEN
else say msg
if em.rc < 6 then return 0
call V_CLEANUP
exit em.rc
ERROR_MESSAGE_SCREEN:
if em.rc < 8
then type.error = 'non-critical'
else type.error = 'critical'
title = gv.cmd.name
msg.line.0 = 3
msg.line.1 = 'The following' type.error 'error has occured:'
msg.line.2 = ''
msg.line.3 = msg
button = VMsgBox(title,msg.line,1)
return 0
FINISHED_MESSAGE: procedure expose gv.
title = gv.cmd.name
msg.line.0 = 1
msg.line.1 = title 'ENDING.'
if symbol('gv.v.initcode') = 'VAR'
then button = VMsgBox(title,msg.line,1)
else say msg.line.1
return 0
HELP_MESSAGE: procedure expose gv.
title = gv.cmd.name
msg.line.0 = 1
msg.line.1 = 'No help found for' title
if symbol('gv.v.initcode') = 'VAR'
then max.line = 10
else max.line = 20
do j = 1 to 1000
if j \= 1 and help.line = ''
then return 0
do i = 1 to max.line
if help.line = ''
then return 0
help.line = linein(gv.cmd.name'.HLP')
if help.line = ''
then leave
msg.line.i = help.line
msg.line.0 = i
end
if symbol('gv.v.initcode') = 'VAR'
then do
button = VMsgBox(title,msg.line,1)
iterate j
end
do i = 1 to msg.line.0
say msg.line.1
end
if help.line = ''
then leave
say '<MORE>'
pull response
end
return 0