home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
viscobv7.zip
/
vac22os2
/
ibmcobol
/
macros
/
copyfile.lx
< prev
next >
Wrap
Text File
|
1998-02-27
|
61KB
|
2,052 lines
/* REXX */
trace off;
signal on novalue;
parse source opsys . whoami rest;
if opsys = 'OS/2' then
do;
env = 'OS2ENVIRONMENT';
callit = '@Call';
call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs';
call SysLoadFuncs;
end;
else
do;
env = 'ENVIRONMENT';
callit = '@Rexx';
end;
exit_rc = 0;
setdoc = 'no';
setpos = 'no';
setposl = 'no';
setpos3 = 'no';
'extract doctype into doctype';
if translate(doctype) <> 'CBL' then
call errmsg 'Action valid only for CBL files';
tempdir = value('TMP',,env);
tempout = SysTempFileName(tempdir'\TM?????.OUT');
parse upper arg type type2 type3 type4 type5 rest;
parse upper arg dummy path;
parse arg dummy pathasis;
parse arg dummy saveargs;
blanks = ' ';
blanks = blanks||blanks||blanks||blanks;
if type <> 'INIT' then
do;
'extract classes into classes';
if wordpos('CPYFILE',classes) = 0 then
call errmsg 'Copy file facility has not been initialized';
'extract docnum into docnum';
'extract global.cpyfile_readproj_'docnum 'into readproj';
if readproj = 'no' then
call read_project;
end;
select;
when type = 'NOP' then
nop;
when type = 'INIT' then
call init;
when type = 'EXPAND' then
call expand;
when type = 'CONTRACT' then
call contract;
when type = 'REFRESH' then
call refresh;
when type = 'HIDE' then
call hide;
when type = 'IPATH' then
call ipath;
when type = 'SET' then
call set;
when type = 'EDIT' then
call edit;
when type = 'LPEXCMD' then
call lpexcmd;
when type = 'DELETE' then
call delete;
when type = 'SAVECMD' then
call savecmd;
when type = 'MENU' then
call menu;
when type = 'POPUP' then
call popup;
when type = 'LSHELP' then
call lshelp;
when type = 'NAVIG' then
call navig;
when type = 'CLEANUP' then
call cleanup;
when type = 'HELP' then
call help;
otherwise
call errmsg 'Invalid request type' type;
end;
exit exit_rc;
/* */
expand:
call check_syntax;
call get_path;
call get_copy;
return;
/* */
check_syntax:
'extract class into class';
if wordpos('MESSAGE',class) > 0 | wordpos('MVSMSG',class) > 0 |,
wordpos('CPYHEAD',class) > 0 then
call errmsg 'Not positioned at a COPY statement';
call get_content;
if substr(content,7,1) <> ' ' then
call errmsg 'Not positioned at a COPY statement';
data = substr(content,1,72);
data = substr(data,8);
data = strip(data,'T');
if length(data) < 2 then
data = ' 'data;
if substr(data,length(data),1) = '.' then
do;
len = length(data) - 1;
data = substr(data,1,len);
end;
parse upper var data arg1 arg2 arg3 arg4 rest;
if arg1 <> 'COPY' then
call errmsg 'Not positioned at a COPY statement';
if arg2 = '' then
call errmsg 'Name of COPY file missing';
if length(arg2) > 8 then
call errmsg 'Copy file names longer than eight characters not supported:',
arg2;
if substr(arg2,1,1) = '"' | substr(arg2,1,1) = "'" then
call errmsg 'Literal for copy file name not supported:' arg2;
copyname = arg2;
copylib = '';
if arg3 = 'IN' | arg3 = 'OF' then
do;
if arg4 = '' then
call errmsg 'Name of COPY library missing';
if length(arg4) > 8 then
call errmsg 'Library names longer than eight characters not supported:',
arg4;
copylib = arg4;
end;
if copylib = '' then
copylibs = '';
else
copylibs = '/'copylib;
copyname2 = copyname||copylibs;
copynames = substr(copyname||copylibs' ',1,17);
'extract element into element';
'extract elements into elements';
if element < elements then
do;
'mark set @@cpyfile2@@';
'next';
'extract class into class';
'extract content into content';
'mark find @@cpyfile2@@';
'mark clear @@cpyfile2@@';
if wordpos('CPYFILE',class) > 0 then
do;
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest level;
if copytest = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
if copytest = copyname2 then
call errmsg 'Copy file is already expanded';
end;
end;
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
do;
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest level;
if copytest = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
end;
else
level = 0;
return;
/* */
get_path:
'extract docnum into docnum';
'extract global.cpyfile_workdir_'docnum 'into workdir';
'extract global.cpyfile_ipath_'docnum 'into ipath';
if ipath = '**null**' then
ipath = '';
if length(ipath) > 0 then
do;
if substr(ipath,length(ipath),1) <> ';' then
ipath = ipath||';';
end;
ipaths = ipath;
copylibo = copylib;
if copylib = '' then
copylib = 'SYSLIB';
libpath = getenv(copylib);
libpath = strip(libpath,'B');
libpath = translate(libpath);
if length(libpath) > 0 then
do;
if substr(libpath,length(libpath),1) <> ';' then
libpath = libpath||';';
end;
libpaths = libpath;
curpath = translate(workdir);
if substr(curpath,length(curpath),1) <> '\' then
curpath = curpath||'\';
suffices = '.CPY .CBL .COB *';
do ii = 1 to words(suffices);
suffix = word(suffices,ii);
if suffix = '*' then
suffix = '';
if copylibo = '' then
do;
copypath = curpath||copyname||suffix;
/* xx = SysFileTree(copypath,'ts.','F'); */ /* use bypass instead */
call testfile copypath;
if ts.0 > 0 then
return;
ipath = ipaths;
if ipath <> '' then
do;
do forever;
if ipath = '' then
leave;
if pos(';',ipath) = 0 then
leave;
parse var ipath path ';' ipath;
if substr(path,length(path),1) <> '\' then
path = path||'\';
copypath = path||copyname||suffix;
/* xx = SysFileTree(copypath,'ts.','F'); */ /* use bypass instead */
call testfile copypath;
if ts.0 > 0 then
return;
end;
end;
end;
libpath = libpaths;
do forever;
if libpath = '' then
leave;
if pos(';',libpath) = 0 then
leave;
parse var libpath path ';' libpath;
if substr(path,length(path),1) <> '\' then
path = path||'\';
copypath = path||copyname||suffix;
/* xx = SysFileTree(copypath,'ts.','F'); */ /* use bypass instead */
call testfile copypath;
if ts.0 > 0 then
return;
end;
end;
if copylibo = '' then
call errmsg 'Cannot find copy file' copyname;
else
call errmsg 'Cannot find copy file' copyname arg3 copylibo;
/* */
read_project:
'extract docnum into docnum';
'extract name into name';
if substr(name,2,2) <> ':\' then
call errmsg 'Do not understand file name' name;
lastslash = lastpos('\',name);
if lastslash > 3 then
lastslash = lastslash - 1;
workdir = substr(name,1,lastslash);
workdir = translate(workdir);
'set global.cpyfile_workdir_'docnum workdir;
'set global.cpyfile_readproj_'docnum 'yes';
'extract project into project';
if project = '' then
return;
workdir = '';
read_stem.0 = 0;
xx = linein(project,1,0);
do forever;
if lines(project) = 0 then
leave;
read_stem.0 = read_stem.0 + 1;
nn = read_stem.0;
read_stem.nn = linein(project);
end;
xx = stream(project,'C','CLOSE');
if read_stem.0 > 0 then
do;
do ii = 1 to read_stem.0;
record = read_stem.ii;
if substr(record,1,12) = '+defaultDir=' then
do;
workdir = substr(record,13);
workdir = strip(workdir,'T');
if workdir = '' then
leave;
do forever;
if pos('\\',workdir) = 0 then
leave;
parse var workdir workdir1 '\\' workdir2;
workdir = workdir1'\'workdir2;
end;
end;
end;
if substr(workdir,2,2) <> ':\' then
call errmsg 'Invalid or missing working directory for project' project;
workdir = translate(workdir);
'set global.cpyfile_workdir_'docnum workdir;
end;
else
call errmsg 'Project file' project 'could not be read or was empty';
if read_stem.0 > 0 then
do;
do ii = 1 to read_stem.0;
record = read_stem.ii;
if substr(record,1,12) = '+defaultDir=' then
do;
workdir = substr(record,13);
workdir = strip(workdir,'T');
if workdir = '' then
leave;
do forever;
if pos('\\',workdir) = 0 then
leave;
parse var workdir workdir1 '\\' workdir2;
workdir = workdir1'\'workdir2;
end;
end;
if substr(record,1,4) = '+var' then
do;
parse var record dummy '=' varname '=' varval;
varname = translate(varname);
call setvar;
end;
end;
end;
return;
/* */
setvar:
varname = translate(varname);
varval = translate(varval);
'extract docnum into docnum';
'extract global.cpyfile_workdir_'docnum 'into workdir';
found = 'yes';
varval = strip(varval,'B');
do forever;
if pos('\\',varval) = 0 then
leave;
parse var varval varval1 '\\' varval2;
varval = varval1'\'varval2;
end;
do forever;
if pos('%',varval) = 0 then
leave;
if lastpos('%',varval) = pos('%',varval) then
leave;
parse var varval varval1 '%' envname '%' varval2;
varval = varval1||getenv(envname)||varval2;
end;
if length(varval) > 0 then
do;
if substr(varval,length(varval),1) <> ';' then
varval = varval||';';
end;
varval2 = '';
do forever;
if varval = '' then
leave;
if pos(';',varval) = 0 then
leave;
parse var varval val ';' varval;
select;
when val = '' then
nop;
when substr(val,1,2) = '..' then
do;
val = substr(val,3);
if length(workdir) = 3 then
do;
'msg Cannot determine higher directory for' varname;
'alarm';
found = 'no';
leave;
end;
lastslash = lastpos('\',workdir);
workdirh = substr(workdir,1,lastslash);
if length(workdirh) > 3 then
workdirh = substr(workdirh,1,length(workdirh) - 1);
end;
when substr(val,1,1) = '.' then
do;
val = substr(val,2);
if val = '' then
val = workdir;
else
do;
if substr(workdir,length(workdir),1) = '\' then
val = workdir||substr(val,2);
else
val = workdir||val;
end;
end;
when substr(val,1,1) = '\' then
val = substr(workdir,1,2)||val;
when substr(val,2,2) <> ':\' then
do;
if substr(workdir,length(workdir),1) = '\' then
val = workdir||val;
else
val = workdir||'\'||val;
end;
otherwise
nop;
end;
varval2 = varval2||val||';';
end;
if found = 'yes' then
do;
if varval2 = '' then
varval2 = '**null**';
'set global.cpyfile_envvar_'docnum'_'varname varval2;
'extract global.cpyfile_envvars_'docnum 'into envvars';
if wordpos(varname,envvars) = 0 then
'set global.cpyfile_envvars_'docnum envvars varname;
end;
return;
/* */
get_copy:
do forever;
thedate = date('U');
thetime = time('L');
marktime = substr(thedate,1,2)||,
substr(thedate,4,2)||substr(thedate,7,2)||substr(thetime,1,2)||,
substr(thetime,4,2)||substr(thetime,7,2)||substr(thetime,10,2);
markname0 = '@@cpyfilee0@@'||marktime;
markname1 = '@@cpyfilee1@@'||marktime;
markname2 = '@@cpyfilee2@@'||marktime;
'extract mark.'markname1 'into marktest';
if marktest = 0 then
leave;
end;
newlevel = level + 1;
newlevel = substr('0'newlevel,length(newlevel),2);
font8 = '888888888888888888888888888888888888888888';
font8 = font8||font8||font8||font8;
fontv = 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv';
fontv = fontv||fontv||fontv||fontv;
font9 = '99999999999999999999999999'||fontv;
fonty = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
fonty = fonty||fonty||fonty||fonty;
fontus = '________';
equals = '==========================================';
equals = equals||equals||equals||equals;
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@'newlevel;
setposl = 'yes';
'extract docnum into docnum';
'set global.cpyfile_expanded_'docnum 'yes';
'extract global.cpyfile_color_'docnum 'into color';
'extract global.cpyfile_fast_'docnum 'into fast';
'extract global.cpyfile_navig_'docnum 'into navig';
if navig = 'on' then
do;
if color <> 'BASE' then
do;
if fast = 'FAST' then
'msg Navigator will not show expanded copy files';
else
'msg Refresh within Navigator will not show expaned copy files';
'alarm';
end;
'set global.cpyfile_navig_'docnum 'msg';
end;
'extract actionbarid.LP_VIEW.Hide_copy_files into hide';
'set menuactive.'hide 'on';
'extract exclude into exclude';
cpyfilepos = wordpos('CPYFILE',exclude);
if cpyfilepos > 0 then
do;
exclude = delword(exclude,cpyfilepos,1);
'set exclude' exclude;
end;
do;
'mark set' markname0;
'extract recording into recording';
'extract limiterror into limiterror';
'extract readonly into readonly';
'set recording off';
'set limiterror ignore';
'set readonly off';
numequal = newlevel * 3;
arrow = substr(equals,1,numequal)||'>';
newline = arrow 'Start copy' copypath;
newline = substr(newline,1,80);
call addlines newline;
'mark set' markname1;
'mark set @@cpyfile@@'newlevel'top'
newline = arrow 'End copy' copypath;
newline = substr(newline,1,80);
call addlines newline;
'mark set' markname2;
'mark find @@cpyfile@@'newlevel;
/* maybe a before trigger c program and an after trigger pgm? */
'mark find @@cpyfile@@'newlevel'top' /* find our insert point */
'mark clear @@cpyfile@@'newlevel'top' /* be neat */
'mcpi' copynames newlevel marktime copypath /* expand the copyfile */
mcpi_rc = rc;
'set readonly' readonly;
'set limiterror' limiterror;
'set recording' recording;
if mcpi_rc = 100 then
call errmsg "mcpi: too few parameters - got:" copynames newlevel marktime copypath
if mcpi_rc = 150 then call errmsg "mcpi: class CPYFILE not available in this edit session"
if mcpi_rc = 200 then call errmsg "copyfile:" copypath "cannot be opened"
if mcpi_rc = 250 then call errmsg "copyfile:" copypath "is empty"
if mcpi_rc = 300 then call errmsg "copyfile: error reading file" copypath
if mcpi_rc <> 0 then call errmsg "mcpi non-zero return code:" mcpi_rc
end;
/*
else
call errmsg 'Copy file' copypath 'has no lines'; */
if type3 <> 'INNER' then
do;
'mark find @@cpyfile@@'newlevel;
'set focus.next' cursorrow;
end;
'mark clear @@cpyfile@@'newlevel;
return;
/* */
addline:
parse arg theline;
theline = substr(theline||blanks,1,80)' COPY' copynames newlevel copypath;
theline = substr(theline||blanks,1,80)' COPY' copynames newlevel marktime copypath;
'lxn insert' theline;
'extract class into class';
'set class' class 'CPYFILE';
return;
/* */
addlines:
parse arg thelines;
call addline thelines;
'extract class into class';
'set class' class 'CPYHEAD';
'set show on';
data = substr(thelines,1,72); /* from tweeking noted above */
data = strip(data,'T'); /* */
'extract fonts into fonts'; /* */
newfonts = substr(font8,1,length(data))||fonty; /* */
newfonts = substr(newfonts,1,80)||font9; /* */
newfonts = substr(newfonts,1,length(fonts)); /* */
'set fonts' newfonts; /* --------------------------*/
return;
/* */
color:
parse upper arg thecolor '!' thecolor2 '!' thecolor3;
if thecolor = 'DEFAULT' | thecolor = '' then
thecolor = 'BASE';
'extract docnum into docnum';
'set global.cpyfile_color_'docnum thecolor;
if thecolor = 'BASE' then
usecolor = 'light grey';
else
usecolor = thecolor;
if thecolor2 = '' then
usecolor2 = usecolor;
else
usecolor2 = thecolor2;
if thecolor3 = '' then
usecolor3 = 'LIGHT GREY';
else
usecolor3 = thecolor3;
'set font.8 red/'usecolor2;
'set font.9' usecolor3'/white';
if usecolor3 <> 'WHITE' then
do;
'set font.z' usecolor3'/grey';
'set font.w' usecolor3'/light grey';
end;
else
do;
'set font.z grey/grey';
'set font.w light grey/light grey';
end;
'set font.y red/'usecolor;
'set font.@ black/'usecolor;
'set font.# black/'usecolor;
'set font.$ bright red/'usecolor;
'set font.a black/'usecolor;
'set font.m cyan/'usecolor;
'set font.g underline bright blue/'usecolor;
'set font.o cyan/'usecolor;
'set font.j black/'usecolor;
'set font.k black/'usecolor;
'set font.1 cyan/'usecolor;
'set font.2 pink/'usecolor;
'set font.3 pink/'usecolor;
'set font.4 pink/'usecolor;
'set font.5 green/'usecolor;
'set font.6 bright blue/'usecolor;
'set font.7 bright blue/'usecolor;
return;
/* */
expandfile:
return;
/* */
contract:
'extract class into class';
if wordpos('CPYFILE',class) = 0 then
call errmsg 'Not positioned at a line from a copy file';
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copyname = substr(eyecatcher,7);
parse var copyname copyname level;
if copyname = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
if type2 <> 'ALL' & type2 <> 'CLEANUP' then
do;
'extract blocktype into blocktype';
if blocktype = 'UNSET' then
do;
marktime = substr(content,108,14);
markname0 = '@@cpyfilee0@@'||marktime;
markname1 = '@@cpyfilee1@@'||marktime;
markname2 = '@@cpyfilee2@@'||marktime;
'extract mark.'markname1 'into marktest';
if marktest = 0 then
call errmsg 'Internal error, starting mark not found';
'extract mark.'markname2 'into marktest';
if marktest = 0 then
call errmsg 'Internal error, ending mark not found';
'extract autoparse into autoparse';
'set autoparse off';
'extract parser into parser';
'extract deleting into deleting';
'set parser';
'extract readonly into readonly';
'extract recording into recording';
'set recording off';
'set readonly off';
'set deleting';
'mark find' markname1;
'block mark element';
'mark find' markname2;
'block mark element';
'lxn block delete';
'set parser' parser;
'set autoparse' autoparse;
'trigger';
'set deleting' deleting;
'set readonly' readonly;
'set recording' recording;
'mark find' markname0;
'primitive beginelement';
'mark clear' markname0;
'mark clear' markname1;
'mark clear' markname2;
return;
end;
end;
'extract element into element';
if element > 1 then
do;
do forever;
'prev';
'extract class into class';
if wordpos('MESSAGE',class) = 0 & wordpos('MVSMSG',class) = 0 then
do;
if wordpos('CPYFILE',class) = 0 then
do;
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'next';
leave;
end;
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest leveltest;
if copytest = '' | leveltest = '' then
call errmsg 'Internal error, unknown copy file line';
if wordpos('CPYHEAD',class) > 0 then
do;
if pos('End copy',content) > 0 & leveltest = 01 then
do;
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'next';
leave;
end;
end;
if type2 <> 'ALL' & type2 <> 'CLEANUP' then
do;
if copytest <> copyname & leveltest <= level then
do;
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'next';
leave;
end;
end;
end;
'extract element into element';
if element = 1 then /* prevent infinite loop */
leave;
end;
end;
'extract autoparse into autoparse';
'set autoparse off';
'extract parser into parser';
'extract deleting into deleting';
'set parser';
'extract readonly into readonly';
'extract recording into recording';
'set recording off';
'set readonly off';
'set deleting';
atlast = 'no';
numstart = 0;
do forever;
'extract class into class';
if wordpos('MESSAGE',class) > 0 | wordpos('MVSMSG',class) > 0 then
nop;
else
do;
if wordpos('CPYFILE',class) = 0 then
leave;
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest leveltest;
if copytest = '' | leveltest = '' then
call errmsg 'Internal error, unknown copy file line';
if type2 <> 'CLEANUP' then
do;
if wordpos('CPYHEAD',class) > 0 then
do;
if pos('Start copy',content) > 0 & leveltest = 01 then
do;
numstart = numstart + 1;
if numstart > 1 then
leave;
end;
end;
end;
if type2 <> 'ALL' & type2 <> 'CLEANUP' then
do;
if copytest <> copyname & leveltest <= level then
leave;
end;
end;
'lxn delete';
if atlast = 'yes' then
leave;
'extract elements into elements';
'extract element into element';
if element >= elements then /* prevent infinite loop */
atlast = 'yes';
end;
'set parser' parser;
'set autoparse' autoparse;
'trigger';
'set deleting' deleting;
'set readonly' readonly;
'set recording' recording;
if setpos = 'yes' then
do;
'mark find @@cpyfile@@';
'mark clear @@cpyfile@@';
'set focus.next' cursorrow;
end;
return;
/* */
contractfile:
return;
/* */
refresh:
'extract class into class';
if wordpos('CPYFILE',class) = 0 then
call errmsg 'Not positioned at a line from a copy file';
'macro copyfile.lx contract' type2;
'macro copyfile.lx expand' type2;
return;
/* */
hide:
'extract exclude into exclude';
if wordpos('CPYFILE',exclude) = 0 then
'set exclude' exclude 'CPYFILE';
return;
/* */
ipath:
if path = '' then
path = '**null**';
'extract docnum into docnum';
'set global.cpyfile_ipath_'docnum path;
return;
/* */
set:
if pos('=',path) = 0 then
do;
'extract docnum into docnum';
parse upper var path varname;
if varname = '' then
do;
'extract global.cpyfile_envvars_'docnum 'into envvars';
numvars = words(envvars);
if numvars > 0 then
do;
do ii = 1 to numvars;
envvar = word(envvars,ii);
'extract global.cpyfile_envvar_'docnum'_'envvar 'into envval';
if envval = '**null**';
then envval = '(null)';
'msg' envvar'='envval;
end;
end;
else
'msg No copy file environment variables set';
return;
end;
'extract global.cpyfile_envvar_'docnum'_'varname 'into envval';
if envval = '' then
do;
envval = getenv(varname);
if envval = '' then
envval = '(null)';
end;
else
do;
if envval = '**null**';
then envval = '(null)';
end;
'msg' varname'='envval;
return;
end;
parse upper var path varname '=' varval;
if varname = '' then
call errmsg 'Variable name missing';
call setvar;
return;
/* */
edit:
copyname = '';
copypath = '';
'extract class into class';
if wordpos('MESSAGE',class) = 0 & wordpos('MVSMSG',class) = 0 &,
wordpos('CPYHEAD',class) = 0 then
do;
call get_content;
if substr(content,7,1) = ' ' then
do;
data = substr(content,1,72);
data = substr(data,8);
data = strip(data,'T');
if length(data) < 2 then
data = ' 'data;
if substr(data,length(data),1) = '.' then
do;
len = length(data) - 1;
data = substr(data,1,len);
end;
parse upper var data arg1 arg2 arg3 arg4 rest;
if arg1 = 'COPY' & arg2 <> '' then
do;
if length(arg2) > 8 then
call errmsg,
'Copy file names longer than eight characters not supported:',
arg2;
if substr(arg2,1,1) = '"' | substr(arg2,1,1) = "'" then
call errmsg,
'Literal for copy file name not supported:' arg2;
copyname = arg2;
copylib = '';
if arg3 = 'IN' | arg3 = 'OF' then
do;
if arg4 = '' then
call errmsg 'Name of COPY library missing';
if length(arg4) > 8 then
call errmsg,
'Library names longer than eight characters not supported:',
arg4;
copylib = arg4;
end;
end;
end;
end;
if copyname = '' then
do;
'extract class into class';
if wordpos('CPYFILE',class) = 0 then
call errmsg 'Not positioned at a line from a copy file';
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copyname = substr(eyecatcher,7);
parse var copyname copyname level;
if copyname = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
copypath = substr(content,123);
if copypath = '' then
call errmsg 'Internal error, unknown copy file line';
/*xx = SysFileTree(copypath,'ts.','F'); */ /* use bypass instead */
call testfile copypath;
if ts.0 = 0 then
call errmsg 'Copy file' copypath 'no longer exists';
end;
if copypath = '' then
call get_path;
copydrive = substr(copypath,1,2);
copydrive = translate(copydrive);
filetype = 'local';
mvsinfoQ = translate('IWZM_MVSINFO.DAT_YALE');
oldq = rxqueue('Set',mvsinfoQ);
numqueue = queued();
qname = rxqueue('Set',oldq);
if numqueue > 0 then
do;
xx = Get_MVSINFO();
if xx <> 0 then
call errmsg 'Error getting MVS information';
call Set_MVSINFO_Vars;
if numdrive > 0 then
do;
do ii = 1 to numdrive;
if drive.ii = copydrive then
do;
filetype = 'mvs';
leave;
end;
end;
end;
end;
if filetype = 'local' then
do;
mvsinfoQ = translate('IBMM_MVSINFO.DAT_YALE');
oldq = rxqueue('Set',mvsinfoQ);
numqueue = queued();
qname = rxqueue('Set',oldq);
if numqueue > 0 then
do;
xx = Get_MVSINFO();
if xx <> 0 then
call errmsg 'Error getting MVS information';
call Set_MVSINFO_Vars;
if numdrive > 0 then
do;
do ii = 1 to numdrive;
if drive.ii = copydrive then
do;
filetype = 'mvs';
leave;
end;
end;
end;
end;
end;
if filetype = 'local' then
'lx' copypath '/doctype cpy';
else
do;
product = '';
'extract messages into messages';
'extract beeplength into beeplength';
'set messages off';
'set beeplength 0';
'macroload iwzmtdc.lx';
macroload_rc = rc;
if macroload_rc = 0 then
do;
'macrodrop iwzmtdc.lx';
product = 'cobol';
end;
else
do;
'macroload ibmmtdc.lx';
macroload_rc = rc;
if macroload_rc = 0 then
do;
'macrodrop ibmmtdc.lx';
product = 'pli';
end;
end;
'set messages' messages;
'set beeplength' beeplength;
if product = '' then
call errmsg 'Editor version does not support Remote Edit';
qname = RxQueue('Create');
if product = 'cobol' then
'macro iwzmtdc.lx' qname copypath;
else
'macro ibmmtdc.lx' qname copypath;
oldq = RxQueue('Set',qname);
rcode = linein('QUEUE:');
xx = RxQueue('Set',oldq);
xx = RxQueue('Delete',qname);
if rcode = 4 then
do;
if product = 'cobol' then
address cmd callit 'iwzmscm.cmd' callit 'iwzmedi.cmd' copypath;
else
address cmd callit 'ibmmscm.cmd' callit 'ibmmedi.cmd' copypath;
end;
end;
return;
/* */
stale_mark:
return;
/* */
lpexcmd:
rwcmds1 = 'DELETE';
rwcmds2 = 'GET OPENLINC';
rwcmds3 = 'SPLITLINC';
noparsecmds = 'CLIP BLOCK DELETE SPLITJOIN';
lxicmds = 'OPENLINC SPLITLINC';
parse upper var path thecmd restsave;
parse upper var restsave cmdarg cmdarg2 rest;
if thecmd = 'FIND' then
do;
parse var pathasis dummy rest;
restu = translate(rest);
testpos1 = wordpos('ANY',restu);
testpos2 = wordpos('ASIS',restu);
select;
when testpos1 = 0 & testpos2 = 0 then
testpos = 0;
when testpos1 = 0 & testpos2 > 0 then
testpos = pos(' ASIS',' 'restu) - 1;
when testpos1 > 0 & testpos2 = 0 then
testpos = pos('ANY',restu);
when testpos1 > 0 & testpos2 > 0 then
do;
if testpos1 < testpos2 then
testpos = pos('ANY',restu);
else
testpos = pos(' ASIS',' 'restu) - 1;
end;
otherwise
testpos = 0;
end;
if testpos > 0 then
do;
if pos('COLUMNS',restu) = 0 | pos('COLUMNS',restu) > testpos then
do;
cols = '1 80'
if testpos = 1 then
findcmd = 'COLUMNS' cols rest;
else
do;
part3 = substr(rest,testpos);
len = testpos - 1;
part1 = substr(rest,1,len);
findcmd = part1 'COLUMNS' cols part3;
end;
'lxn find' findcmd;
find_rc = rc;
exit find_rc;
end;
end;
'lxn find' rest;
find_rc = rc;
exit find_rc;
end;
thecmd2 = '';
if thecmd = 'SPLITJOIN' then
do;
if cmdarg = 'SPLIT' | cmdarg = 'JOIN' then
thecmd2 = cmdarg;
else
do;
'extract content into content';
'extract cursorpos into cursorpos';
restcontent = substr(content,cursorpos);
if restcontent = ' ' then
thecmd2 = 'JOIN'
else
thecmd2 = 'SPLIT';
end;
end;
if thecmd = 'BLOCK' then
do;
if cmdarg = 'MOVE' | cmdarg = 'COPY' then
do;
if cmdarg2 = 'BEFORE' then
thecmd2 = 'BEFORE';
else
thecmd2 = 'AFTER';
end;
end;
'extract class into class';
if thecmd = 'CLIP' & cmdarg = 'PASTE' then
do;
if wordpos('CPYFILE',class) > 0 then
call errmsg 'Expanded copy file is read/only';
end;
if wordpos(thecmd,rwcmds1) > 0 | thecmd2 = 'JOIN' |,
thecmd2 = 'BEFORE' then
do;
if wordpos('CPYFILE',class) > 0 then
call errmsg 'Expanded copy file is read/only';
end;
if wordpos(thecmd,rwcmds2) > 0 | wordpos(thecmd,rwcmds3) |,
thecmd2 = 'SPLIT' | thecmd2 = 'AFTER' then
do;
if wordpos('CPYFILE',class) > 0 then
do;
if thecmd2 = 'AFTER' then
do;
'extract blocktype into blocktype';
if blocktype <> 'ELEMENT' then
call errmsg 'Expanded copy file is read/only';
end;
if wordpos('CPYHEAD',class) = 0 then
call errmsg 'Expanded copy file is read/only';
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest leveltest;
if copytest = '' | leveltest = '' then
call errmsg 'Internal error, unknown copy file line';
if pos('End copy',content) = 0 | leveltest <> 01 then
call errmsg 'Expanded copy file is read/only';
if wordpos(thecmd,rwcmds3) > 0 | thecmd2 = 'SPLIT' then
do;
'extract cursorpos into cursorpos';
if cursorpos <> (length(content) + 1) then
call errmsg 'Expanded copy file is read/only';
end;
end;
end;
if thecmd = 'BLOCK' & (cmdarg = 'MOVE' | cmdarg = 'DELETE') then
do;
'extract docnum into docnum';
'extract blockdoc into blockdoc';
if blockdoc <> docnum then
'godoc docnum' blockdoc;
setdoc = 'yes';
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'block find';
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
call errmsg 'Expanded copy file is read/only';
'block find end';
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
do;
if wordpos('CPYHEAD',class) = 0 then
call errmsg 'Expanded copy file is read/only';
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest leveltest;
if copytest = '' | leveltest = '' then
call errmsg 'Internal error, unknown copy file line';
if pos('End copy',content) = 0 | leveltest <> 01 then
call errmsg 'Expanded copy file is read/only';
end;
'mark find @@cpyfile@@';
'mark clear @@cpyfile@@';
'godoc docnum' docnum;
end;
if thecmd = 'CLIP' | thecmd = 'BLOCK' then
do;
if (thecmd = 'CLIP' & cmdarg = 'CUT') |,
(thecmd = 'BLOCK' &,
wordpos(cmdarg,'SHIFT LOWER UPPER FILL') > 0) then
do;
'extract docnum into docnum';
'extract blockdoc into blockdoc';
if blockdoc <> docnum then
'godoc docnum' blockdoc;
setdoc = 'yes';
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'block find';
'extract element into element1';
'block find end';
'extract element into element2';
'find element' element1;
do forever;
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
call errmsg 'Expanded copy file is read/only';
'extract element into element';
if element >= element2 then
leave;
'next';
end;
'mark find @@cpyfile@@';
'mark clear @@cpyfile@@';
'godoc docnum' docnum;
end;
if thecmd = 'BLOCK' then
do;
'extract blocktype into blocktype';
if cmdarg = 'OVERLAY' | (blocktype = 'RECTANGLE' &,
(cmdarg = 'MOVE' | cmdarg = 'COPY')) then
do;
'extract docnum into docnum';
'extract blockdoc into blockdoc';
if blockdoc <> docnum then
'godoc docnum' blockdoc;
'extract cursorrow into cursorrow';
'mark set @@cpyfile@@';
setpos = 'yes';
'block find';
'extract element into element1';
'block find end';
'extract element into element2';
numelems = element2 - element1 + 1;
'godoc docnum' docnum;
'mark find @@cpyfile@@';
do ii = 1 to numelems;
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
call errmsg 'Expanded copy file is read/only';
'extract element into element';
'extract elements into elements';
if element >= elements then
leave;
'next';
end;
'mark find @@cpyfile@@';
'mark clear @@cpyfile@@';
end;
end;
end;
if thecmd = 'BLOCK' then
do;
if cmdarg = 'MOVE' then
do;
'extract docnum into docnum_before_move';
'set global.cpyfile_move_'docnum 'on';
end;
end;
if wordpos(thecmd,lxicmds) > 0 then
'lxi' path;
else
'lxn' path;
lpexcmd_rc = rc;
if lpexcmd_rc <> 0 then
exit_rc = lpexcmd_rc;
if thecmd = 'BLOCK' then
do;
if cmdarg = 'MOVE' then
do;
'godoc docnum' docnum_before_move;
end;
end;
if thecmd = 'BLOCK' & lpexcmd_rc >= 0 then
do;
'extract docnum into docnum';
'extract blockdoc into blockdoc';
if cmdarg = 'COPY' then
do;
'extract blocktype into blocktype';
if blockdoc = docnum & blocktype = 'ELEMENT' then
do;
'mark set @@cpyfileb@@';
'block find';
'extract element into element1';
'block find end';
'extract element into element2';
numelems = element2 - element1 + 1;
delmsg = 'no';
'find element' element1;
do ii = 1 to numelems;
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
do;
'extract content into content';
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest level;
if copytest = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
end;
if wordpos('CPYFILE',class) > 0 & wordpos('CPYHEAD',class) > 0 then
do;
delmsg = 'yes';
'extract deleting into deleting';
'set deleting';
'lxn delete';
'set deleting' deleting;
end;
else
do;
if wordpos('CPYFILE',class) > 0 then
do;
'set show off';
cpyfilepos = wordpos('CPYFILE',class);
newclass = delword(class,cpyfilepos,1);
'set class' newclass;
'extract content into content';
content = substr(content,1,80);
content = strip(content,'T');
'set content' content;
end;
'next';
end;
end;
'trigger';
if delmsg = 'yes' then
'msg Expanded copy file header lines deleted on copy';
'mark find @@cpyfileb@@';
'mark clear @@cpyfileb@@';
end;
end;
if cmdarg = 'MOVE' then
do;
'extract global.cpyfile_move_'docnum 'into movestat';
if movestat = 'contract' then
do;
if blockdoc = docnum then
do;
'mark set @@cpyfileb@@';
'block find end';
call get_content;
if substr(content,7,1) = ' ' then
do;
data = substr(content,1,72);
data = substr(data,8);
data = strip(data,'T');
if length(data) < 2 then
data = ' 'data;
if substr(data,length(data),1) = '.' then
do;
len = length(data) - 1;
data = substr(data,1,len);
end;
parse upper var data arg1 arg2 arg3 arg4 rest;
if arg1 = 'COPY' & arg2 <> '' then
do;
iscopy = 'yes';
if length(arg2) > 8 | substr(arg2,1,1) = '"' |,
substr(arg2,1,1) = "'" then
iscopy = 'no';
else
do;
copylib = '';
if arg3 = 'IN' | arg3 = 'OF' then
do;
if arg4 = '' | length(arg4) > 8 then
iscopy = 'no';
else
copylib = arg4;
end;
end;
if iscopy = 'yes' then
do;
'macro copyfile.lx expand';
'msg Associated expanded copy file re-expanded';
end;
end;
end;
'mark find @@cpyfileb@@';
'mark clear @@cpyfileb@@';
end;
end;
'set global.cpyfile_move_'docnum 'off';
end;
end;
return;
/* */
delete:
return;
/* */
savecmd:
'extract classes into classes';
if pos('MVSMSG',classes) = 0 then
'lxn save' saveargs;
else
do;
mvsinfoQ = translate('IWZM_MVSINFO.DAT_YALE');
oldq = rxqueue('Set',mvsinfoQ);
numqueue = queued();
qname = rxqueue('Set',oldq);
if numqueue > 0 then
'macro iwzmsav.lx' saveargs;
else
'macro ibmmsav.lx' saveargs;
end;
save_rc = rc;
if save_rc = 0 then
do;
newargs = '';
inquote = 'no';
sepchar = '01'x;
if length(saveargs) > 0 then
do;
do ii = 1 to length(saveargs);
thechar = substr(saveargs,ii,1);
select;
when thechar = '"' then
do;
if inquote = 'yes' then
inquote = 'no';
else
inquote = 'yes';
newargs = newargs||thechar;
end;
when thechar == ' ' then
do;
if inquote = 'yes' then
newargs = newargs||sepchar;
else
newargs = newargs||thechar;
end;
otherwise
newargs = newargs||thechar;
end;
end;
end;
do ii = 1 to 12;
thearg.ii = word(newargs,ii);
thearg.ii = translate(thearg.ii,' ',sepchar);
end;
a1 = thearg.1;
'extract name into savename';
if a1 <> '' then
do;
if substr(a1,1,1) <> '/' then
savename = a1;
end;
savename = strip(savename,'B','"');
call stale_mark savename;
end;
return;
/* */
menu:
if type2 <> 'FULL' & type2 <> 'SHORT' then
call errmsg 'Invalid MENU request type' type2;
if type2 = 'FULL' then
do;
end;
else
do;
'extract popupmenu.Expand_copy_file_all into menutest';
if menutest <> '' then
do;
'set popupmenu.Expand_copy_file_all';
'set popupmenu.Expand_all_copy_files';
'set popupmenu.Contract_copy_file_all';
'set popupmenu.Contract_all_copy_files';
'set popupmenu.Refresh_copy_file_all';
'set popupmenu.Refresh_all_copy_files';
'set popupmenu.Cleanup';
end;
end;
return;
/* */
popup:
doexpand = 'no';
docontract = 'no';
docontractall = 'no';
dorefresh = 'no';
doedit = 'no';
doclean = 'no';
'extract class into class';
if wordpos('CPYFILE',class) > 0 then
do;
docontract = 'yes';
dorefresh = 'yes';
doedit = 'yes';
end;
'extract docnum into docnum';
'extract global.cpyfile_expanded_'docnum 'into expanded';
if expanded = 'yes' then
do;
docontractall = 'yes';
doclean = 'yes';
end;
'extract class into class';
if wordpos('MESSAGE',class) = 0 & wordpos('MVSMSG',class) = 0 &,
wordpos('CPYHEAD',class) = 0 then
do;
call get_content;
if substr(content,7,1) = ' ' then
do;
data = substr(content,1,72);
data = substr(data,8);
data = strip(data,'T');
if length(data) < 2 then
data = ' 'data;
if substr(data,length(data),1) = '.' then
do;
len = length(data) - 1;
data = substr(data,1,len);
end;
iscopy = 'no';
parse upper var data arg1 arg2 arg3 arg4 rest;
if arg1 = 'COPY' & arg2 <> '' then
do;
if length(arg2) <= 8 & substr(arg2,1,1) <> '"' &,
substr(arg2,2,1) <> "'" then
do;
iscopy = 'yes';
copyname = arg2;
copylib = '';
if arg3 = 'IN' | arg3 = 'OF' then
do;
if arg4 = '' | length(arg4) > 8 then
iscopy = 'no';
else
copylib = arg4;
end;
end;
end;
if iscopy = 'yes' then
do;
doedit = 'yes';
doexpand = 'yes';
if copylib = '' then
copylibs = '';
else
copylibs = '/'copylib;
copyname2 = copyname||copylibs;
'extract element into element';
'extract elements into elements';
if element < elements then
do;
'mark set @@cpyfile2@@';
'next';
'extract class into class';
'extract content into content';
'mark find @@cpyfile2@@';
'mark clear @@cpyfile2@@';
if wordpos('CPYFILE',class) > 0 then
do;
eyecatcher = substr(content,81,26);
if substr(eyecatcher,1,6) <> ' COPY ' then
call errmsg 'Internal error, unknown copy file line';
copytest = substr(eyecatcher,7);
parse var copytest copytest level;
if copytest = '' | level = '' then
call errmsg 'Internal error, unknown copy file line';
if copytest = copyname2 then
doexpand = 'no';
end;
end;
end;
end;
end;
'extract popupmenuid.Expand_copy_file into expand';
'extract popupmenuid.Contract_copy_file into contract';
'extract popupmenuid.Refresh_copy_file into refresh';
'extract popupmenuid.Edit_copy_file into edit';
'extract popupmenu.Expand_copy_file_all into menutest';
if menutest <> '' then
do;
'extract popupmenuid.Expand_copy_file_all into expandall';
'extract popupmenuid.Expand_all_copy_files into expandallfile';
'extract popupmenuid.Contract_copy_file_all into contractall';
'extract popupmenuid.Contract_all_copy_files into contractallfile';
'extract popupmenuid.Refresh_copy_file_all into refreshall';
'extract popupmenuid.Refresh_all_copy_files into refreshallfile';
'extract popupmenuid.Cleanup into cleanup';
end;
if doexpand = 'yes' then
do;
'set menuactive.'expand 'on';
if menutest <> '' then
'set menuactive.'expandall 'on';
end;
else
do;
'set menuactive.'expand 'off';
if menutest <> '' then
'set menuactive.'expandall 'off';
end;
if docontract = 'yes' then
do;
'set menuactive.'contract 'on';
if menutest <> '' then
'set menuactive.'contractall 'on';
end;
else
do;
'set menuactive.'contract 'off';
if menutest <> '' then
'set menuactive.'contractall 'off';
end;
if menutest <> '' then
do;
if docontractall = 'yes' then
'set menuactive.'contractallfile 'on';
else
'set menuactive.'contractallfile 'off';
if doclean = 'yes' then
'set menuactive.'cleanup 'on';
else
'set menuactive.'cleanup 'off';
end;
if dorefresh = 'yes' then
do;
'set menuactive.'refresh 'on';
if menutest <> '' then
'set menuactive.'refreshall 'on';
end;
else
do;
'set menuactive.'refresh 'off';
if menutest <> '' then
'set menuactive.'refreshall 'off';
end;
if doedit = 'yes' then
'set menuactive.'edit 'on';
else
'set menuactive.'edit 'off';
return;
/* */
lshelp:
return;
/* */
navig:
return;
/* */
cleanup:
return;
/* */
get_content:
'extract content into content';
content = substr(content||blanks,1,80);
'extract class into tstclass';
if wordpos('MESSAGE',tstclass) > 0 | wordpos('MVSMSG',tstclass) > 0 |,
wordpos('CPYHEAD',tstclass) > 0 then
return;
if substr(content,7,1) <> ' ' then
return;
tstdata = substr(content,1,72);
tstdata = substr(tstdata,8);
tstdata = strip(tstdata,'T');
tstdata = ' 'tstdata;
poscopy = pos(' COPY ',translate(tstdata));
if poscopy = 0 then
return;
tstdata = substr(tstdata,(poscopy + 1));
posperiod = pos('.',tstdata);
if posperiod > 0 then
tstdata = substr(tstdata,1,posperiod);
extra = poscopy - 1;
if extra > 0 then
tstdata = substr(blanks,1,extra)||tstdata;
tstdata = substr(tstdata||blanks,1,65);
content = substr(content,1,7)||tstdata||substr(content,73,8);
return;
/* */
testfile:
/* This code is used to bypass the SdU problem where doing either a */
/* DIR command or a SysFileTree on a non-existent member will return */
/* data as if the member exists. */
parse upper arg copypatht;
copypatht = strip(copypatht,'T');
if substr(copypatht,2,2) <> ':\' then
call errmsg 'Do not understand file name' copypatht;
xx = SysFileTree(copypatht,'ts.','F');
if ts.0 = 0 then /* if file not found then file really does not exist */
return;
parse var ts.1 v0 v1 v2 .;
if v2 > 0 then /* if non-zero length file then file really exists */
return;
/* If file length is zero then need to do a generic search to see if */
/* the file really exists. For this to work on SdU the leading part */
/* of the search must be less than eight characters. */
lastslash = lastpos('\',copypatht);
copypatht2 = substr(copypatht,1,lastslash);
copypatht2r = substr(copypatht,(lastslash + 1));
if copypatht2r = '' then
call errmsg 'Do not understand file name' copypatht;
if length(copypatht2r) < 8 then
copypatht2r = copypatht2r||'*';
else
copypatht2r = substr(copypatht2r,1,7)||'*';
copypatht2 = copypatht2||copypatht2r;
xx = SysFileTree(copypatht2,'ts.','F');
if ts.0 = 0 then /* if no files found then file really does not exist */
return;
do ii = 1 to ts.0; /* search through found files for desired file */
parse upper var ts.ii v0 v1 v2 v3 v4;
if copypatht = v4 then
return;
end;
ts.0 = 0; /* no match so set to show file not found */
return;
/* */
init:
'set actionbar.LP_VIEW.Hide_copy_files 8 macro copyfile.lx hide';
'set actionbar.LP_HELP.Expand_copy_file_help 7 copyfile.lx help';
'set popupmenu.separator 98';
'set popupmenu.Expand_copy_file macro copyfile.lx expand';
'set popupmenu.Contract_copy_file macro copyfile.lx contract';
'set popupmenu.Refresh_copy_file macro copyfile.lx refresh';
'set popupmenu.Edit_copy_file macro copyfile.lx edit';
'extract actionbarid.LP_VIEW.Hide_copy_files into hide';
'extract popupmenuid.Expand_copy_file into expand';
'extract popupmenuid.Contract_copy_file into contract';
'extract popupmenuid.Refresh_copy_file into refresh';
'extract popupmenuid.Edit_copy_file into edit';
'set menuactive.'hide 'off';
'set menuactive.'expand 'off';
'set menuactive.'contract 'off';
'set menuactive.'refresh 'off';
'set menuactive.'edit 'off';
'set popupinit macro copyfile.lx popup';
'set synonym.block cpyblk';
'set synonym.clip macro copyfile.lx lpexcmd clip';
'set synonym.delete macro copyfile.lx lpexcmd delete';
'set synonym.get macro copyfile.lx lpexcmd get';
'set synonym.splitjoin macro copyfile.lx lpexcmd splitjoin';
'extract synonym.openline into openline';
if openline <> '' then
do;
'set synonym.openlinc' openline;
'set synonym.openline macro copyfile.lx lpexcmd openlinc';
end;
'extract synonym.splitline into splitline';
if splitline <> '' then
do;
'set synonym.splitlinc' splitline;
'set synonym.splitline macro copyfile.lx lpexcmd splitlinc';
end;
/* 'set deleting macro copyfile.lx delete'; */
/* 'set protect' protect 'CPYFILE CPYHEAD'; */
'set font.v light grey/white';
/* 'set find.columnnums 1 80';
'set find.columns on'; */
/* 'set synonym.find macro copyfile.lx lpexcmd find'; */
'extract docnum into docnum';
if type3 = 'STALE' then
do;
'set global.cpyfile_stale_'docnum 'ON';
'set synonym.save macro copyfile.lx savecmd';
end;
else
'set global.cpyfile_stale_'docnum 'OFF';
if type4 = '' then
type4 = 'DEFAULT';
type4 = translate(type4,' ','_');
call color type4;
if type5 = '' then
type5 = 'FAST';
'set global.cpyfile_fast_'docnum type5;
'set global.cpyfile_navig_'docnum 'off';
/*'SET ACTION.F1 macro copyfile.lx lshelp'; */
/* 'SET ACTIONBAR.LP_VIEW.Na~vigator.~Open macro copyfile.lx navig open';
'SET HELP. 16806';
'SET ACTIONBAR.LP_VIEW.Na~vigator.Refresh macro copyfile.lx navig refresh';
'SET HELP. 16806'; */
'set global.cpyfile_readproj_'docnum 'no';
return;
/* */
getenv:
parse upper arg envvar;
'extract docnum into docnume';
'extract global.cpyfile_envvar_'docnume'_'envvar 'into envval';
if envval <> '' then
do;
if envval = '**null**' then
envval = '';
envval = strip(envval,'T');
return envval;
end;
if opsys = 'Windows95' then
envval = value(envvar,,env);
else
do;
qname = RxQueue('Create');
if opsys = 'OS/2' then
address cmd '@start /c /i /min copyfile.cmd' qname envvar;
else
address cmd '@start /i /min rexx copyfile.cmd' qname envvar;
oldq = RxQueue('Set',qname);
envval = linein('QUEUE:');
envval = substr(envval,2);
xx = RxQueue('Set',oldq);
xx = RxQueue('Delete',qname);
end;
envval = strip(envval,'T');
envval2 = envval;
if envval2 = '' then
envval2 = '**null**';
'set global.cpyfile_envvar_'docnume'_'envvar envval2;
return envval;
/* */
errmsg:
parse arg themsg;
if setpos = 'yes' then
do;
'mark find @@cpyfile@@';
'mark clear @@cpyfile@@';
'set focus.next' cursorrow;
end;
if setposl = 'yes' then
do;
if type3 <> 'INNER' then
do;
'mark find @@cpyfile@@'newlevel;
'set focus.next' cursorrow;
end;
'mark clear @@cpyfile@@'newlevel;
end;
if setpos3 = 'yes' then
do;
'mark find @@cpyfile3@@';
'mark clear @@cpyfile3@@';
'set focus.next' cursorrow;
end;
if setdoc = 'yes' then
'godoc docnum' docnum;
'msg' themsg;
'alarm';
exit 16;
/* */
Get_MVSINFO:
rtn = 0
null = '0000'x
crlf = '0D0A'x
mvsinfo. = ''
oldq = rxqueue('Set',mvsinfoQ) /* switch to mvsinfo queue */
if queued() = 0 then do
qname = rxqueue('Set',oldq) /* restore normal queue */
return 4;
end;
parse pull mvsstuff; push mvsstuff /* get/replace Q contents */
parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
/* timestamp and cobolroot */
if ts <> 'Sven' then do;
mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
bad_mvsinfo = ' **' whoami '****'crlf' **error*' mvsinfo,
'is unavailable, missing or empty **'
/* Following use of SysFileTree does not need bypass since it is */
/* for a file on a real workstation drive, i.e it cannot be an */
/* SdU drive on MVS. */
x=SysFileTree(mvsinfo,'ts','F') /* get MVSINFO.DAT's timestamp */
if ts.0 <> 1 then do
say bad_mvsinfo
return 12;
end
parse var ts.1 v0 v1 v2 .
timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
end;
else
timestamp = 'Yale'
if timestamp <> ts then do /* timestamps match? */
pull mvsstuff /* no, remove bad contents */
if product = 'cobol' then
rtn = "IWZMIR.CMD"() /* ask for new stuff */
else
rtn = "IBMMIR.CMD"() /* ask for new stuff */
if rtn = 0 then do
parse pull mvsstuff; push mvsstuff /* get/replace Q contents */
/* remove timestamp and */
/* cobolroot */
parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
end
end
qname = rxqueue('Set',oldq) /* restore normal queue */
do while (mvsstuff<>'') & (rtn=0) /* mvsinfo. structure */
parse value mvsstuff with key val (null) mvsstuff
if mvsinfo.key = '' then do /* e.g. mvsinfo.TYPE='' */
mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
mvsinfo.key.1 = val /* e.g. mvsinfo.TYPE.1=val */
mvsinfo.key = 1 /* e.g. mvsinfo.TYPE=1 */
end
else do
x = mvsinfo.key + 1 /* e.g. mvsinfo.TYPE+1 */
mvsinfo.key.x = val /* e.g. mvsinfo.TYPE.2=val */
mvsinfo.key = x /* e.g. mvsinfo.TYPE=2 */
end
end
return rtn
Set_MVSINFO_Vars:
parse var mvsinfo.DRIVE numdrive;
if numdrive = '' then
numdrive = 0;
do ii = 1 to numdrive;
parse var mvsinfo.DRIVE.ii,
drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
end;
return
/* */
help:
helpname = '"COBOL Expand Copy Files Help Information"';
'godoc find' helpname;
'extract doclist into doclist';
if words(doclist) > 0 then
do;
'extract name into name';
name = translate(name);
if name = helpname then
return; /* help already loaded */
end;
'lx' helpname '/asis';
'extract recording into recording';
'set recording off';
numhelp = 0;
call showhelp;
'msg ';
'set readonly on';
'set recording' recording;
'top';
return;
/* */
showhelp:
call ah 'The COBOL Expand Copy Files facility allows you to expand';
call ah 'the contents of copy files inline.';
call ah;
call ah 'The following forms of the COPY statement are supported:';
call ah;
call ah 'COPY copyname.';
call ah;
call ah 'COPY copyname IN libname.';
call ah;
call ah 'COPY copyname OF libname.';
call ah;
call ah 'The copyname must be a one to eight character simple file';
call ah 'name, such as MYCOPY, with no file extension or path';
call ah 'information specified. The copyname is assumed to not be';
call ah 'a reference to an environment variable. The libname must be';
call ah 'a one to eight character environment variable name, such as';
call ah 'MYLIB or SYSLIB. The replacing phrase may be specified, but';
call ah 'is ignored, meaning the expanded copy file is shown asis.';
call ah 'Except for an optional replacing phrase, the COPY statement';
call ah 'must appear on one line that contains no other statements,';
call ah 'however, a construct such as the following is also supported:';
call ah;
call ah ' 01 WORK-FIELDS. COPY WORKVARS.';
call ah;
call ah;
call ah;
call ah 'The expanded copy file lines have the following properties:';
call ah;
call ah '- they are preceded and followed by a line indicating the';
call ah ' full path of the copy file. The same search algorithm';
call ah ' as the COBOL compiler is used to find the copy file.';
call ah;
call ah '- they are read only, which means you cannot type over them,';
call ah ' nor are they saved when the file is saved';
call ah;
call ah '- they appear with the same language sesitivity (such as';
call ah ' color) as the rest of the file';
call ah;
call ah 'Expanded copy files may be hidden from view by selecting the';
call ah '"View" menu-bar choice and then selecting "Hide copy files".';
call ah 'Expanding a copy file will cause hidden copy files to be';
call ah 'shown.';
call ah;
call ah;
call ah;
call ah 'The following functions are supported:';
call ah;
call ah 'Expand a copy file:';
call ah;
call ah ' Position the cursor to the desired COPY statement to be';
call ah ' expanded, click on mouse button 2 (usually the right mouse';
call ah ' button) and choose "Expand copy file". A single level of';
call ah ' copy file is expanded following the COPY statement.';
call ah;
call ah 'Contract an expanded copy file:';
call ah;
call ah ' Position the cursor to any line from the expanded copy file,';
call ah ' click on mouse button 2 (usually the right mouse button) and';
call ah ' choose "Contract copy file". The expanded copy file and any';
call ah ' expanded inner copy files will be contracted.';
call ah;
call ah 'Refresh an expanded copy file:';
call ah;
call ah ' Position the cursor to any line from the expanded copy file,';
call ah ' click on mouse button 2 (usually the right mouse button) and';
call ah ' choose "Refreshcopy file". The expanded copy file will be';
call ah ' refreshed. Any previously expanded inner copy file must be';
call ah ' manually re-expanded if desired.';
call ah;
call ah ' An expanded copy file is not automatically updated when the';
call ah ' underlying file is updated. The refresh function may be';
call ah ' used to refresh the expansion after the underlying file has';
call ah ' been updated.';
call ah;
call ah 'Edit a copy file:';
call ah;
call ah ' Position the cursor to the desired COPY statement to be';
call ah ' edit, click on mouse button 2 (usually the right mouse';
call ah ' button) and choose "Edit copy file". An edit session will';
call ah ' be started for the copy file. The same search algorithm';
call ah ' as the COBOL compiler is used to find the copy file. If';
call ah ' the copy file is on MVS, the "Connect MVS drives" action';
call ah ' must have previously been issued to establish a connection';
call ah ' to MVS.';
call ah;
call ah 'Edit an expanded copy file:';
call ah;
call ah ' Position the cursor to any line from the expanded copy file,';
call ah ' click on mouse button 2 (usually the right mouse button) and';
call ah ' choose "Edit copy file". An edit session will be started';
call ah ' for the copy file. Note, if you position to a COPY';
call ah ' statement within the expanded copy file, the request will be';
call ah ' interpreted as applying to the copy file associated with the';
call ah ' COPY statement as opposed to the expanded copy file itself.';
call ah ' You can always position to the header or trailer line';
call ah ' associated with the expanded copy file if you want to';
call ah ' insure that the request will apply to the expanded copy file';
call ah ' itself.';
call ah ;
call ah 'Set an environment variable for copy file search:';
call ah;
call ah ' Position the cursor to the Editor command line and enter';
call ah ' the following command:';
call ah;
call ah ' copyfile set varname=path';
call ah;
call ah ' For example, to set MYLIB to point to D:\MYCOPY followed by';
call ah ' D:\YOURCOPY enter the command:';
call ah;
call ah ' copyfile set mylib=d:\mycopy;d:\yourcopy';
call ah;
call ah ' As another example, to add E:\THECOPY to the beginning of';
call ah ' of SYSLIB enter the command:';
call ah;
call ah ' copyfile set syslib=e:\thecopy;%syslib%';
return;
/* */
ah:
parse arg thehelp;
numhelp = numhelp + 1;
if numhelp = 1 then
'set content' thehelp;
else
'lxn insert' thehelp;
'set show on';
return;