Mainframe Utility: UNSTRING

Module


ISREDIT MACRO (HELP)
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
/******************************************************************/
/* 'UNSTRING' EDIT MACRO. CREATE CLIST TO CREATE TEST GDG INDEXES */
/* AUTHOR : DAVID LEIGH    DATE : 10-11-88                        */
/******************************************************************/

IF &HELP = &STR(HELP) THEN GOTO HELPSEC

SET TEMPDSN = &STR(&SYSUID..TEMP.UNSTRING.OUTPUT)
DELETE '&TEMPDSN'

FREE DD(TEMPDD)
ALLOCATE DDNAME(TEMPDD) +
         DSN('&TEMPDSN') +
         NEW CATALOG +
         UNIT(SYSDA) VOLUME(WRK$$$) +
         SPACE(1,1) CYLINDERS RELEASE +
         BLKSIZE(23440) LRECL(80) RECFM(F B) DSORG(PS)

ISREDIT (LRECL) = LRECL
ISREDIT CURSOR = 1 1
SET COUNT = 0
OPENFILE TEMPDD OUTPUT

ISREDIT FIND FIRST P'¬'
DO WHILE &LASTCC = 0
    SET COUNT = &COUNT + 1
    ISREDIT (LN1,CL1) = CURSOR
    ISREDIT FIND NEXT ' ' .ZCSR .ZCSR
    IF &LASTCC ¬= 0 THEN ISREDIT CURSOR = &LN1 &LRECL
    ISREDIT (LN2,CL2) = CURSOR
    ISREDIT (LINE) = LINE .ZCSR
    SET TEMPDD = &SUBSTR(&CL1:&CL2,&STR(&SYSNSUB(1,&LINE)))
    PUTFILE TEMPDD
    ISREDIT FIND NEXT P'¬'
END

CLOSFILE TEMPDD
FREE DDNAME(TEMPDD)
ISREDIT CURSOR = 0 1

IF &COUNT > 0 THEN +
    DO
        SET &ZEDLMSG = &STR(&COUNT STRINGS WERE FOUND....+
                            USE "END" CMD TO RETURN TO PREVIOUS EDIT)
        ISPEXEC SETMSG MSG(UTLZ000)
        ISPEXEC EDIT DATASET('&TEMPDSN')
    END
ELSE +
    DO
        SET &ZEDSMSG = &STR(NO STRINGS FOUND)
        SET &ZEDLMSG = &STR(NO STRINGS DELIMITED BY SPACES WERE FOUND)
        ISPEXEC SETMSG MSG(UTLZ001)
        DELETE '&TEMPDSN'
    END

EXIT

HELPSEC: +
CLEAR
WRITE *** HELP FOR EDIT MACRO 'UNSTRING' ***
WRITE
WRITE THE UNSTRING EDIT MACRO SEARCHES THE FILE YOU ARE EDITING, AND
WRITE CREATES A SECOND FILE OF ALL THE INDIVIDUAL STRINGS (ANYTHING DE-
WRITE LIMITED BY SPACES) IT FINDS, WITH ONE STRING PER LINE.
WRITE
WRITE BASIC SYNTAX :
WRITE
WRITE COMMAND ===> UNSTRING
WRITE 000001 THIS IS AN EXAMPLE FILE WITH MANY STRINGS IN IT.
WRITE
WRITE THE OUTPUT FILE WOULD LOOK LIKE THIS :
WRITE 000001 THIS
WRITE 000002 IS
WRITE 000003 AN
WRITE 000004 EXAMPLE
WRITE 000005 FILE
WRITE 000006 WITH
WRITE 000007 MANY
WRITE 000008 STRINGS
WRITE 000009 IN
WRITE 000010 IT.
WRITE
WRITE WHEN THE USER TYPES 'UNSTRING' ON THE COMMAND LINE, THE MACRO
WRITE SEARCHES THE INPUT FILE AND BUILDS THE OUTPUT FILE AND THEN TAKES
WRITE THE USER INTO AN EDIT SESSION OF THE OUTPUT FILE.
WRITE
WRITE NOTE : IF THE INPUT FILE IS A CLIST OR CONTAINS MANY '(', ')', OR
WRITE        '&', THE UNSTRING EDIT MACRO MAY HAVE A PROBLEM WITH IT DUE
WRITE        TO THE WAY TSO PROCESSES THESE STRINGS.  IT SHOULD BE USED
WRITE        PRIMARILY FOR NARRATIVE TYPE TEXT FILES.
WRITE
WRITE *** END OF HELP *** NO PROCESSING PERFORMED ***

EXIT
            


Documentation


 This utility scans a file being edited and creates a seperate file with a line
 for each string delimited by spaces (or beginning or end of line) in the first
 file.  You are then taken into an ISPF EDIT of the output dataset (the input
 dataset is unchanged), and you are returned to the edit of the input dataset
 when you "END" or "CANCEL" out of the output dataset.  Example :

 Input file :                           Output file :
 000100 string1 string2 (string3) xx    000100 string1
                                        000200 string2
                                        000300 (string3)
                                        000400 xx
            


Leave a Reply

Your email address will not be published. Required fields are marked *