I wanted to know if there is any way in CLIST to identify symbol '&' in a string. I want to handle a situation in my CLIST where if the input string passed to CLIST contains '&' then do XYZ (for say)
At the moment its not accepting any CLIST inbuilt functions which i can use to check if '&' is present anywhere in the string.
I always receive an error with function used saying :-
IKJ56545I THIS STATEMENT HAS AN INVALID SYMBOLIC VARIABLE
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
ok..its going to be a long post:
The Purpose of this REXX code was to search for the OLD string and replace it with a new string in a PDS.
Rexx Main Code:
Code:
/******************REXX*******************/
ISREDIT "MACRO PROCESS"
TRACE I
PROF NOPREF
PANEL="YYYYY.REXX.PANEL"
ADDRESS ISPEXEC "LIBDEF ISPPLIB DATASET ID(&PANEL) UNCOND"
DO FOREVER
INPUT1 = ' '
INPUT2 = ' '
ADDRESS ISPEXEC "DISPLAY PANEL(PNL1)"
"ISPEXEC VGET (ZPFKEY) ASIS"
"ISPEXEC VPUT (INPUT1) SHARED"
"ISPEXEC VPUT (INPUT2) SHARED"
"ISPEXEC VPUT (MDSN) SHARED"
DISRC1 = RC
IF ZPFKEY = 'PF03' THEN
LEAVE
IF INPUT1 \= ' ' THEN
DO
IF INPUT2 \= ' ' THEN
DO
IF SYSDSN(MDSN) \= "OK" THEN
"ISPEXEC VPUT (INPUT1) SHARED"
"ISPEXEC VPUT (INPUT2) SHARED"
X=OUTTRAP('N.')
SAY MDSN
"LISTDS" MDSN "MEMBER"
X=OUTTRAP('OFF')
SAY " "
SAY "TOTAL" N.0-6 "MEMBERS OF",
MDSN "TO BE PROCESSED.........."
SAY "MEMBERS STATUS "
DO I=7 TO N.0
MEM=STRIP(N.I,B)
MYFILE=MDSN || '(' || MEM || ')'
ADDRESS ISPEXEC "EDIT DATASET("MYFILE") MACRO(IM001)"
SAY MEM " PROCESSED SUCCESSFULLY"
END
DROP N.
END
END
When you will execute the main REXX it will show you below Panel, which will ask you to input OLD string, New String and PDS name.
Here My Inputs are:
OLD STRING = &AB
NEW STRING = &CD
Code:
---------------------------------------------------------------------
| ------------------ CHANGE STRING UTILITY -------------------- |
| | | |
| | | |
| | OLD STRING NAME : &AB | |
| | NEW STRING NAME : &CD | |
| | ENTER PDS NAME : XXXXX.TEST.CNTLLIB | |
| | | |
| | | |
| ----------------------------------------------------------------- |
---------------------------------------------------------------------
COMMAND ===>
<PF1>=HELP ENTER-TO PROCESS F3- END/CANCEL
My INPUT PDS has a member which has foloowing data:
Code:
000001 &AB1
000002 &AB2
It does not change &AB to &CD , but if my inputs are &&&&AB and &&&&CD then it does the change.
If Sysvar(SYSISPF) \= "ACTIVE" Then Do
Say left(_cmd,8)"- Ispf is not active. Command not executed"
Exit 4
End
/*
call $ispex "CONTROL ERRORS RETURN"
*/
call $ispex "FTOPEN TEMP"
If Sysvar(SYSISPF) \= "ACTIVE" Then Do
Say left(_cmd,8)"- Ispf is not active. Command not executed"
Exit 4
End
zerralrm = "NO"
zerrhm = "ISR2MACR"
call $ispex "CONTROL ERRORS RETURN"
if $isred("MACRO (ZPARMS) NOPROCESS ") \= 0 then do
zerrsm = "Invocation ERROR"
zerrlm = left(_cmd,8)"- Must be invoked as an edit macro"
call $ispex "SETMSG MSG(ISRZ001) "
Exit 1
end
if $ispex("VGET (FSTR,TSTR,OPTS,XTRG,ITRG) SHARED" ) = 0 then do
if strip(itrg) = "" then ,
irc = 0
else
irc = $isred("FIND '&&itrg.' FIRST")
if strip(xtrg) = "" then ,
xrc = 4
else
xrc = $isred("FIND '&&xtrg.' FIRST")
if irc = 0 & xrc = 4 then do
call $isred "CHANGE '&&fstr.' '&&tstr.' " opts
call $isred "(CHGS,ERRS) = CHANGE_COUNTS"
call $ispex "VPUT (CHGS,ERRS) SHARED"
if errs = 0 then do
call $isred "END"
exit 0
end
end
end
call $isred "CANCEL"
exit 1
VIEW ENRICO.SPFTEMP2.CNTL Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 CHGALL - Dataset : 'ENRICO.TEST.PDS'
000002 CHGALL - From String : 'zqw'
000003 CHGALL - To String : '&&&'
000004 CHGALL - Options : 'ALL'
000005
000006 CHGALL - Member : 'A ' NOT CHANGED
000007 CHGALL - Member : 'AMP ' changes(7) errors()
000008 CHGALL - Member : 'B ' NOT CHANGED
000009 CHGALL - Member : 'C ' NOT CHANGED
000010
000011 CHGALL - Members : 4
000012
000013
****** **************************** Bottom of Data ****************************
the same member
Code:
EDIT ENRICO.TEST.PDS(AMP) - 01.05 Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 &&&A
000002 &&&B
000003 &&&C
000004 &&&&&&&&&&&&
****** **************************** Bottom of Data ****************************
another example with arbitrary strings with spaces
the member before
Code:
EDIT ENRICO.TEST.PDS(ARB) - 01.00 Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 SOME STRING WITH BLANKS
****** **************************** Bottom of Data ****************************
the panel
Code:
-------------------------------------------------------------------------------
---------------------------------- Change all ---------------------------------
-------------------------------------------------------------------------------
COMMAND ===>
-------------------------------------------------------------------------------
From String ==> SOME STRING WITH BLANKS
To String ==> the changed string
-------------------------------------------------------------------------------
Options ==> ALL
Mbr Filter ==>
VIEW ENRICO.SPFTEMP2.CNTL Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 CHGALL - Dataset : 'ENRICO.TEST.PDS'
000002 CHGALL - From String : 'SOME STRING WITH BLANKS'
000003 CHGALL - To String : 'the changed string'
000004 CHGALL - Options : 'ALL'
000005
000006 CHGALL - Member : 'A ' NOT CHANGED
000007 CHGALL - Member : 'AMP ' NOT CHANGED
000008 CHGALL - Member : 'ARB ' changes(1) errors()
000009 CHGALL - Member : 'B ' NOT CHANGED
000010 CHGALL - Member : 'C ' NOT CHANGED
000011
000012 CHGALL - Members : 5
000013
000014
****** **************************** Bottom of Data ****************************
the member after
Code:
EDIT ENRICO.TEST.PDS(ARB) - 01.01 Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 THE CHANGED STRING
****** **************************** Bottom of Data ****************************
there is still the glitch of the CAPS for the changed strings
but that' s something easy to take care of
did You notice the smiley
since it' s already done I will upload it again,
the changes spread a bit all over, it will be easier for You to have the whole picture
note note note
the FROM and TO strings can be any valid FROM/TO string accepted by ISPF
done some elementary checking for bad tokens,
a symptom of a missing check is a return code of 20 fro edit
note note note
REXX scripts
MASSCHG
MASSCHG2
panel(s)
MASSCHG
skels
MASSCHG1
MASSCHG2
MASSCHG3
support elements
panel(s)
XNOHELP
messages
XMSG00
the scripts
Code:
/* REXX */
Trace "O"
Parse Source _sys _how _cmd .
chgcmd = _cmd
If Sysvar(SYSISPF) \= "ACTIVE" Then Do
Say left(_cmd,8)"- Ispf is not active. Command not executed"
Exit 4
End
/*
call $ispex "CONTROL ERRORS RETURN"
*/
xRC = $ispex("FTOPEN TEMP")
If xRC \= 0 Then Do
xmsgsm = left(_cmd,8)"- RC("xRC")"
xmsglm = left(_cmd,8)"- RC("xRC") FTOPEN "
call $ispex "SETMSG MSG(XMSG001) "
exit
End
disp = 0
do while ( $ispex("DISPLAY PANEL(MASSCHG) ") = 0 )
call $ispex "VPUT (CMAX, OPTS, exclSTR, inclSTR ) SHARED "
do i = 1 to cmax
if symbol("fromSTR"i) \= "VAR" then
z = value("fromSTR"i,"")
if symbol("toSTR"i) \= "VAR" then
z = value("toSTR"i,"")
call $ispex "VPUT (fromSTR"i" toSTR"i") SHARED "
end
call $ispex "FTINCL MASSCHG1 "
disp = 1
/* LMINIT */
xRC = $ispex("LMINIT DATAID(ID) DATASET("dsnm") ENQ(SHR) ")
If xRC \= 0 Then Do
xmsgsm = left(_cmd,8)"- RC("xRC")"
xmsglm = left(_cmd,8)"- "zerrlm
call $ispex "SETMSG MSG(XMSG001) "
iterate
End
/* LMOPEN */
xRC = $ispex("LMOPEN DATAID("ID") OPTION(INPUT) ")
If xRC \= 0 Then Do
xmsgsm = left(_cmd,8)"- RC("xRC")"
xmsglm = left(_cmd,8)"- "zerrlm
call $ispex "SETMSG MSG(XMSG001) "
call $ispex "LMFREE DATAID("ID") "
iterate
End
if $isred("MACRO (ZPARMS) NOPROCESS ") \= 0 then
exit 8
if $ispex("VGET (cmax,opts,exclSTR,inclSTR) SHARED" ) = 0 then do
do i = 1 to cmax
call $ispex "VGET (fromSTR"i" toSTR"i") SHARED"
end
if strip(inclSTR) = "" then ,
inclRC = 0
else ,
inclRC = $isred("FIND &&inclSTR. FIRST")
if strip(exclSTR) = "" then ,
exclRC = 4
else ,
exclRC = $isred("FIND &&exclSTR. FIRST")
if inclRC = 0 & exclRC = 4 then do
chgs = 0; errs = 0
do i = 1 to cmax
fromSTR = VALUE("fromSTR"i)
if strip(fromSTR) = "" then ,
iterate
toSTR = VALUE("toSTR"i)
xRC = $isred("CHANGE &&fromSTR. &&toSTR. ALL")
call $isred "(C,E) = CHANGE_COUNTS"
chgs = chgs + c
errs = errs + e
end
call $ispex "VPUT (CHGS,ERRS) SHARED"
if errs = 0 then do
call $isred "END"
exit 0
end
end
end
call $isred "CANCEL"
exit 1
*REXX(*,CMAX,XMSGSM,XMSGLM)
do i = 1 to cmax
wstr = translate(strip(VALUE("fromSTR"i)))
if wordpos(wstr,"NEXT PREV FIRST LAST ALL") > 0 then ,
signal strerr
if wordpos(wstr,"CHARS PREFIX SUFFIX WORD") > 0 then ,
signal strerr
if wordpos(wstr,"X NX") > 0 then ,
signal strerr
wstr = translate(strip(VALUE("toSTR"i)))
if wordpos(wstr,"NEXT PREV FIRST LAST ALL") > 0 then ,
signal strerr
if wordpos(wstr,"CHARS PREFIX SUFFIX WORD") > 0 then ,
signal strerr
if wordpos(wstr,"X NX") > 0 then ,
signal strerr
end
zrxrc = 0
return