/* REXX */ /*******************************************************************/ /* This ISPF edit macro will generate numbers in existing lines of */ /* of a dataset. */ /* */ /* COUNT From x To y By z In Column a At Line b With Zeros */ /* */ /* x - The first number to start counting from */ /* (default is From 1). */ /* y - The last number to stop counting at */ /* (default is To the last line). */ /* z - The increment to add to each number when counting */ /* (default is By 1). */ /* a - The column number to place the numbers in the data */ /* (default is In Column 1). */ /* b - The line number where the first number is placed */ /* (default is At Line 1). */ /* With Zeros - Includes the leading zeros of numbers in the data. */ /* */ /* Keywords may be specified with at least one capital letter. */ /*******************************************************************/ /*******************************************************************/ /* Begin macro processing and convert parameter data to uppercase. */ /*******************************************************************/ ADDRESS ISREDIT "MACRO (parm)" PARSE UPPER VAR parm parm_uc ADDRESS ISPEXEC "CONTROL ERRORS RETURN" /********************************************/ /* Initialize variables to default values. */ /********************************************/ start = '1'; stop = ''; incremen = 1 column = '1'; line = '1'; zero = ' ' zeromsg = '' zmsg = '' /******************************/ /* Collect parameter values. */ /******************************/ DO x = 1 TO WORDS(parm_uc) word = WORD(parm_uc,x) SELECT WHEN ABBREV('FROM',word,1) THEN DO x = x + 1 start = WORD(parm_uc,x) END WHEN ABBREV('TO',word,1) THEN DO x = x + 1 stop = WORD(parm_uc,x) END WHEN ABBREV('BY',word,1) THEN DO x = x + 1 incremen = WORD(parm_uc,x) END WHEN ABBREV('IN',word,1) THEN DO x = x + 1 column = WORD(parm_uc,x) IF ABBREV('COLUMN',column) THEN DO x = x + 1 column = WORD(parm_uc,x) END END WHEN ABBREV('COLUMN',word,1) THEN DO x = x + 1 column = WORD(parm_uc,x) END WHEN ABBREV('AT',word,1) THEN DO x = x + 1 line = WORD(parm_uc,x) IF ABBREV('LINE',line) THEN DO x = x + 1 line = WORD(parm_uc,x) END END WHEN ABBREV('LINE',word,1) THEN DO x = x + 1 line = WORD(parm_uc,x) END WHEN ABBREV('WITH',word,1), | ABBREV('ZEROS',word,1) THEN DO zero = '0' zeromsg = 'With Zeros' END OTHERWISE NOP END /* SELECT */ END x /*******************************/ /* Validate parameter values. */ /*******************************/ IF \DATATYPE(start,'N') THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT001)' EXIT 0 END IF \DATATYPE(incremen,'N') THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT003)' EXIT 0 END IF \DATATYPE(column,'W') THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT005)' EXIT 0 END "(lrecl) = LRECL" IF column > lrecl THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT006)' EXIT 0 END IF \DATATYPE(line,'W') THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT008)' EXIT 0 END "SEEK ALL P'=' 1" "(records) = SEEK_COUNTS" IF line > records THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT009)' EXIT 0 END IF stop = '' THEN DO DO x = start BY incremen FOR records - (line - 1); END x stop = x - incremen END stop = STRIP(stop,'L','0') stop = STRIP(stop,'B',' ') stop_length = LENGTH(stop) IF \DATATYPE(stop,'N') THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT002)' EXIT 0 END IF ((start > stop) & (SIGN(incremen) \= -1)), | ((start < stop) & (SIGN(incremen) \= 1)) THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT004)' EXIT 0 END IF column + stop_length - 1 > lrecl THEN DO ADDRESS ISPEXEC 'SETMSG MSG(COUNT007)' EXIT 0 END /*****************************/ /* Perform main processing. */ /*****************************/ generic = "p'"COPIES('=',stop_length)"'" "LOCATE" line DO y = start TO stop BY incremen y = RIGHT(y,stop_length,zero) "CHANGE" generic "'"y"' NEXT CHARS" column END y /*****************************************/ /* Set macro response message and exit. */ /*****************************************/ zmsg = 'COUNT From' start 'To' stop 'By' incremen 'In Column' column, 'At line' line zeromsg ADDRESS ISPEXEC 'SETMSG MSG(COUNT000)' /* See member COUNT00. */ EXIT 0