home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
viscobv7.zip
/
vac22os2
/
ibmcobol
/
macros
/
iwzmssq.lx
< prev
next >
Wrap
Text File
|
1997-12-17
|
8KB
|
173 lines
/* REXX */
/*********************************************************************/
/* */
/* Name: iwzmSSQ.LX */
/* */
/* Function: Allows setting of columns 73-80 to a given value. */
/* LPEX SHOW lines, such as language parser messages */
/* or compilation error messages, are not affected. */
/* This macro is intended fpr processing files that */
/* are logically fixed 80 byte records (even though */
/* on the workstation the records are physically */
/* stored as variable length). */
/* */
/* Note: this macro must be placed in the same directory as other */
/* LPEX macros before it can be invoked. */
/* */
/* Invocation: */
/* */
/* From the LPEX command line enter the following: */
/* */
/* iwzmSSQ seqval <numrow> <REP> */
/* */
/* where: */
/* */
/* The < and > above indicate optional parameters. The */
/* parameters are blank delimited, so extra blanks before or */
/* after a parameter are ignored. */
/* */
/* seqval - the 1 to 8 character value to be placed in columns */
/* 73-80 starting in column 73. The underscore (_) */
/* characters indicates a blank in the value. This */
/* value is case sensitive. */
/* */
/* numrow - the number of rows, starting with the current row, */
/* to be changed. LPEX SHOW lines do not participate */
/* in determining the number of lines to change, i.e. */
/* they are ignored as if they did not exist. If numrow */
/* is not specified then only the current row is */
/* changed. A numrow specification of * indicates */
/* that the change is to be made to all the lines to the */
/* bottom of the file (still starting with the current */
/* line). */
/* */
/* REP - indicates that existing data in columns 73-80 is */
/* to be replaced. The entire data is replaced. If */
/* REP is not specified then lines that already have */
/* non-blank data in columns 73-80 are not changed. */
/* Such rows that are not changed are however counted */
/* as part of the number of rows to be changed. This */
/* parameter is not case sensitive and may be entered */
/* in any case. */
/* */
/* The LPEX position in the file is preserved after invocation, */
/* i.e. after this macro finishes executing you remain in the */
/* same position in the file. */
/* */
/* Examples: */
/* */
/* iwzmSSQ Jan_1997 10 rep */
/* */
/* this causes columns 73-80 of the next 10 lines, starting */
/* with the current line, to be set to the values "Jan 1997" */
/* (not included the quotes). */
/* */
/* iwzmSSQ FIX00357 1000 */
/* */
/* this causes columns 73-80 of the next 1000 lines, starting */
/* with the current line, to be set to FIX00357. Lines that */
/* already had a non-blank value in columns 73-80 are not */
/* changed. */
/* */
/* Restrictions: */
/* */
/* - the file must not be accessed as readonly. */
/* */
/* - the LPEX textlimit for the file must be at least 80. */
/* The normal LPEX default for textlimit is 2499 (even though */
/* you only intend to edit up to 80 bytes per record). */
/* */
/* - if when processing the lines to be changed, a line is */
/* encountered (other than an LPEX SHOW line) that is longer */
/* than 80 characters the processing is terminated. Such a */
/* line implies that the data was not logically fixed 80 byte */
/* records. */
/* */
/*********************************************************************/
trace off;
signal on novalue;
'extract cursorrow into cursorrow';
'mark set @@iwzmssq@@';
numchg = 0;
parse arg seqval numrow replace rest;
if seqval = '' then
call error 'Format is: iwzmssq seqval <numrows <rep>>>';
if length(seqval) > 8 then
call error 'Value for columns 73-80 longer than 8';
seqval = translate(seqval,' ','_');
if translate(numrow) = 'REP' then
do;
replace = 'REP';
numrow = '';
end;
if numrow = '' then
numrow = 1;
if numrow = '*' then
numrow = 999999999;
if datatype(numrow,'W') <> 1 then
call error 'Invalid number of rows';
if numrow < 1 then
call error 'Invalid number of rows';
if replace = '' then
replace = 'NOREPLACE';
replace = translate(replace);
'extract readonly into readonly';
if readonly = 'ON' then
call error 'File is read only';
'extract textlimit into textlimit';
if textlimit < 80 then
call error 'Textlimit set to less that 80';
prevrow = 0;
blanks = ' ';
blanks = blanks||blanks||blanks||blanks||blanks;
'check';
numreal = 0;
do forever;
'extract show into show';
if show = 'OFF' then
do;
numreal = numreal + 1
if numreal > numrow then
leave;
'extract content into line';
if length(line) > 80 then
call error 'Line longer than 80, processing stopped';
dochg = 'yes';
line = line||blanks;
curseq = substr(line,73,8);
if curseq <> '' & substr(replace,1,3) <> 'REP' then
dochg = 'no';
if dochg = 'yes' then
do;
line = substr(line,1,72)||seqval;
line = strip(line,'T');
'set content' line;
set_rc = rc;
if set_rc <> 0 then
call error 'Cannot change line, see macro log for details';
numchg = numchg + 1;
end;
end;
'next';
'extract element into numline';
if numline = prevrow then
leave;
prevrow = numline;
end;
'check';
'msg Lines changed =' numchg;
'mark find @@iwzmssq@@';
'mark clear @@iwzmssq@@';
'set focus.next' cursorrow;
exit 0;
/* */
error:
parse arg errmsg;
'check';
'mark find @@iwzmssq@@';
'mark clear @@iwzmssq@@';
'set focus.next' cursorrow;
'msg' errmsg ', lines changed =' numchg;
'alarm';
exit 4;