Return to Mainframe Utilities Page
Module
ISREDIT MACRO (OPT1,OPT2,OPT3,OPT4,OPT5,OPT6,OPT7)
ISPEXEC CONTROL ERRORS RETURN
/**** SET MESSAGE DISPLAY ON/OFF BASED ON THE DEBUG SWITCH ***/
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN CONTROL MSG LIST CONLIST SYMLIST NOFLUSH
ELSE CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
/**********************************************************************/
/* UTILITY NAME : ONESPACE */
/* AUTHOR : DAVE LEIGH */
/* DESCRIPTION : CHANGE MORE THAN ONE CONTIGUOUS SPACE TO ONLY ONE */
/* : SPACE IN THE AREA SPECIFIED. */
/**********************************************************************/
/**********************************************************************
/* COMBINE THE OPTIONS INTO ONE STRING FOR THE SUBSEQUENT COMMAND. *
/**********************************************************************
SET OPTIONS = &SYSCAPS(&OPT1 &OPT2 &OPT3 &OPT4 &OPT5 &OPT6 &OPT7)
ISREDIT (SLINE,SCOL) = CURSOR
SET COUNT = 0
/**********************************************************************
/* GET LRECL, USER'S POSITION AND CURRENT BOUNDS. *
/**********************************************************************
ISREDIT (LRECL) = LRECL
ISREDIT (SLN,SCL) = CURSOR
ISREDIT (LEFT,RIGHT) = BOUNDS
/**********************************************************************
/* DO IT! *
/**********************************************************************
ISREDIT BOUNDS 1 &LRECL
ISREDIT SEEK FIRST ' ' &STR(&OPTIONS)
DO WHILE &LASTCC = 0
ISREDIT (LN,CL) = CURSOR
ISREDIT SEEK NEXT P'¬' .ZCSR .ZCSR
IF &LASTCC = 0 THEN +
DO
ISREDIT (LN1,CL1) = CURSOR
IF &EVAL(&CL1 - &CL) > 1 THEN +
DO
ISREDIT BOUNDS = &CL &LRECL
ISREDIT SHIFT ( .ZCSR &EVAL(&CL1 - &CL - 1)
ISREDIT BOUNDS 1 &LRECL
END
ISREDIT CURSOR = &LN &CL
END
ELSE +
DO
SET COUNT = &COUNT + 1
IF &EVAL(&COUNT//10) = 0 THEN +
DO
SET ZEDSMSG = &STR(&COUNT LINES PROCESSED)
ISPEXEC CONTROL DISPLAY LOCK
ISPEXEC DISPLAY MSG(UTLZ000W)
END
ISREDIT FIND LAST P'=' .ZCSR .ZCSR
END
ISREDIT SEEK NEXT ' ' &STR(&OPTIONS)
END
ISREDIT CURSOR = &SLN &SCL
ISREDIT BOUNDS = &LEFT &RIGHT
SET ZEDSMSG = &STR(SPACES COMPRESSED)
SET ZEDLMSG = &STR(NO MORE THAN ONE SPACE SEPARATES NON-BLANK CHARS IN +
ANY TARGET AREA)
ISPEXEC SETMSG MSG(UTLZ000)
EXIT
HELPSEC: +
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR ONESPACE UTILITY +
*** NO PROCESSING PERFORMED ***)
ISPEXEC SETMSG MSG(UTLZ000)
EXIT
Documentation
The ONESPACE edit macro reduces any multiple contiguous spaces between any two
non-blank characters to only a single space. This can be for the entire file,
or some portion of it.
The basic syntax of ONESPACE is simple....
COMMAND ===> onespace {optional filtering parameters....}
The filtering parameters would be the same as those you might specify for a
typical edit change command. You can specify specific columns, excluded
status, and system or user edit labels.
A few notes about better ways to do things with ONESPACE. You can specify "X"
or "NX", but specifying "X" probably does not work the way you might think.
Since ONESPACE actually uses a CHANGE ALL command (plus any filtering
parameters you specify), if a line is changed, it is automatically
"un-excluded", and further processing on that line is discontinued (ONESPACE
operates iteratively) so it may not be processed correctly. "NX" will work
correctly, but, it is better to use edit labels or "NX" than "X".
The other caveat involves the specification of colums. When ONESPACE performs
the CHANGE ALL, data may shift from outside of the original column
specification to inside the specification. This may produce positive or
negative results depending upon what you were expecting. If you truly want to
isolate some columns of data, you should specify a BNDS line command and pick
your bounds before invoking ONESPACE.
Finally, it should be noted that you can combine several parameters to come up
with some fairly complex filtering options.

0 Comments