View previous topic :: View next topic
|
Author |
Message |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Hello Everyone,
Hope all are doing well.
Actually, my requirement is to add RLSQUIESCE & LOG parameters to the existing parm cards.
Parm card can have multiple define statements as well.
I have written the rexx code for this requirement but it's not working only if for all scenarios.
Scenario 1:
It's not working when the parameter NIXD, IXD and NUMD are not present. I read in some books that If any of this parameter is not present then it will considered as "KSDS".
INPUT:
Code: |
DELETE (FILE.NAME1) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NAME1) -
CYLINDERS(200 200) -
KEYS(10 0) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( -
NAME(FILE.NAME1.DATA) -
VOLUMES(A ) -
CISZ(4096) -
RECORDSIZE(60 60) -
)
|
Expected OUTPUT:
Code: |
DELETE (FILE.NAME1) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NAME1) -
CYLINDERS(200 200) -
KEYS(10 0) -
RLSQUIESCE -
LOG(UNDO) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( -
NAME(FILE.NAME1.DATA) -
VOLUMES(A )-
CISZ(4096) -
RECORDSIZE(60 60) -
)
|
Scenario 2:
It's not working when the paramet NIXD, IXD and NUMD ends with close brackets ')' like NIDXD).
INPUT:
Code: |
DELETE (FILE.NAME2) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER -
(NAME(FILE.NAME2) -
SHR(2 3) -
KEYS(14 0) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
DATA -
(NAME(FILE.NAME2.DATA) -
CISZ(4096) -
CYL(500 50) -
RECORDSIZE(150 150) -
VOLUMES(A )) -
INDEX -
(NAME(FILE.NAME2.INDEX) -
NOIMBED -
VOLUMES(I ))
|
Expected OUTPUT:
Code: |
DELETE (FILE.NAME2) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER -
(NAME(FILE.NAME2) -
SHR(2 3) -
KEYS(14 0) -
RLSQUIESCE -
LOG(UNDO) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
DATA -
(NAME(FILE.NAME2.DATA) -
CISZ(4096) -
CYL(500 50) -
RECORDSIZE(150 150) -
VOLUMES(A )) -
INDEX -
(NAME(FILE.NAME2.INDEX) -
NOIMBED -
VOLUMES(I ))
|
Scenario 3:
INPUT:
Code: |
DELETE (FILE.NAME3) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NAME3) -
CYL(300 50) -
INDEXED -
NOREUSE -
NOWRITECHECK -
SHR (2 3) -
UNORDERED -
) -
DATA ( -
NAME(FILE.NAME3.DATA) -
VOLUMES(A ) -
CONTROLINTERVALSIZE(4096) -
FREESPACE(20 20) -
KEYS(18 0) -
NOERASE -
RECORDSIZE(1020 1020) -
SPEED -
) -
|
OUTPUT:
Code: |
DELETE (FILE.NAME3) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NAME3) -
CYL(300 50) -
INDEXED -
RLSQUIESCE -
LOG(UNDO) -
NOREUSE -
NOWRITECHECK -
SHR (2 3) -
UNORDERED -
) -
DATA ( -
NAME(FILE.NAME3.DATA) -
VOLUMES(A ) -
CONTROLINTERVALSIZE(4096) -
FREESPACE(20 20) -
KEYS(18 0) -
NOERASE -
RECORDSIZE(1020 1020) -
SPEED -
) -
|
I'm using below macro for adding new attributes.
This is working good for scenario 3 since it found the variable INDEXED but it's not working for scenario 1 & scenario 2..
Code: |
ADDRESS ISREDIT
"MACRO"
/* ============================================================ */
ADDRESS ISREDIT
"(CURRLN) = LINENUM .ZCSR" /* CURRENT LINE */
"(LASTLN) = LINENUM .ZLAST" /* LAST LINE NUMBER */
I = 0
DO FOREVER
I = I + 1
IF I > LASTLN THEN LEAVE
"(LINE) = LINE " I
LINE = SUBSTR(LINE,1,80)
IF SUBSTR(LINE,1,3) = "//*" | SUBSTR(LINE,1,3) = " /*" THEN ITERATE
VAR1 = SUBWORD(LINE,1,1)
UPPER VAR1
PRMT2 = "RLSQUIESCE"||' '||"-"
SELECT
WHEN VAR1 = 'NONINDEXED' | VAR1 = 'NIXD' THEN DO
PRMT3 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRIBUTES
END
WHEN VAR1 = 'INDEXED' | VAR1 = 'IXD' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
END
WHEN VAR1 = 'NUMBERED' | VAR1 = 'NUMD' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
END
OTHERWISE
NOP
END
END
/* EXIT(RC) */
ADDRESS ISPEXEC "ISREDIT SAVE"
ADDRESS ISPEXEC "ISREDIT END"
EXIT 0
/* ------------------------------------------------------------ */
ADD_ATTRIBUTES:
/* ------------------------------------------------------------ */
ADDRESS ISREDIT
LN = I
"ISREDIT LINE_AFTER " LN "= DATALINE '" PRMT2"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
"ISREDIT LINE_AFTER " LN "= DATALINE '" PRMT3"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
RETURN
/* ------------------------------------------------------------ */
/* ============================================================ */
|
I will appreciate your help with this situation.
Thanks,
Nani |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Where is your Trace output? |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Hi Nic,
Thank for your quick response.
My code is working good for scenario 3 because it found the variable INDEXED.
I don't have any idea to fix scenario 1 & scenario 2. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
REXX functions like WORD, SUBWORD, etc. do consider as "word" any sequence between spaces only.
I suggest to change verification of keywords like this:
Code: |
. . . . . . . .
Upper LINE
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0
Number? = Pos( ' NUMBERED', LINE ) > 0 ,
| Pos( ' NUMD', LINE ) > 0
. . . . . . . . . . . . .
SELECT
WHEN NoIndex? THEN DO
PRMT3 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRIBUTES
END
WHEN Index? THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
END
WHEN Number? THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
END
. . . . . . . . .
|
Also update extraction of VAR1 accordingly. It's possible just to use equivalent string constant values, not exactly the original word! |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Quote: |
My code is working good for scenario 3 because it found the variable INDEXED.
I don't have any idea to fix scenario 1 & scenario 2.
|
I know that - you said so in your post. I was asking where your trace output was - you get it by using the Rexx keyword TRACE. |
|
Back to top |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2608 Location: Silicon Valley
|
|
|
|
One thing to watch out for is to have a keyword to appear as part of the object name. For example:
Code: |
DELETE (FILE.NUMD1) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NUMD1) -
CYLINDERS(200 200) -
KEYS(10 0) -
RLSQUIESCE -
LOG(UNDO) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( -
NAME(FILE.NUMD1.DATA) -
VOLUMES(IXD100)-
CISZ(4096) -
RECORDSIZE(60 60) -
) |
Is it likely? Probably not, but I have been burned by that before.
Also, for keywords within comments. I think the input file can have comments. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
Pedro wrote: |
One thing to watch out for is to have a keyword to appear as part of the object name. |
My example two posts above fixes this problem too, in 99.99% of possible cases. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Pedro wrote: |
One thing to watch out for is to have a keyword to appear as part of the object name. For example:
Code: |
DELETE (FILE.NUMD1) PURGE CLUSTER
SET LASTCC=0
SET MAXCC=0
DEFINE CLUSTER ( -
NAME(FILE.NUMD1) -
CYLINDERS(200 200) -
KEYS(10 0) -
RLSQUIESCE -
LOG(UNDO) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( -
NAME(FILE.NUMD1.DATA) -
VOLUMES(IXD100)-
CISZ(4096) -
RECORDSIZE(60 60) -
) |
Is it likely? Probably not, but I have been burned by that before.
Also, for keywords within comments. I think the input file can have comments. |
Yes Input wil have comments but below logic will skip the comments.
LINE = SUBSTR(LINE,1,80)
IF SUBSTR(LINE,1,3) = "//*" | SUBSTR(LINE,1,3) = " /*" THEN ITERATE |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
sergeyken wrote: |
Pedro wrote: |
One thing to watch out for is to have a keyword to appear as part of the object name. |
My example two posts above fixes this problem too, in 99.99% of possible cases. |
Thanks for your quick response.
I believe your code also will help only when the below parameters are present
NONINDEXED,
NIXD,
INDEXED,
IXD,
NUMBERED,
NUMD
Below scenario will not work i.e., scenario 1 in my example.
If these keywords are not present then we need consider as KSDS and default parameter should LOG(UNDO).
Please correct me if i'm wrong. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Hello sergeyken,
If any of the below parameters are not present then need to find for keyword Keys and add the required parameters.
NONINDEXED,
NIXD,
INDEXED,
IXD,
NUMBERED,
NUMD
To overcome this scenarios i have added "Keyp?" & "Defines?" to your code.
Code: |
Defines? = Pos( ' DEFINE', LINE ) > 0
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0
Number? = Pos( ' NUMBERED', LINE ) > 0 ,
| Pos( ' NUMD', LINE ) > 0
Keysp? = Pos( ' KEYS', LINE ) > 0
. . . . . . . . . . . . .
SELECT
WHEN Defines? THEN DO
ADDPERM = 'N'
END
WHEN NoIndex? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Index? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Number? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Keysp? & ADDPERM = 'N' THEN DO
ATTR3 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
. . . . . . . . .
|
It's adding parameters in below scenarios:
1. When there is space between Keys and '(" ex: "KEYS (09 00)" .
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED)
Input:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
|
Output:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
RLSQUIESCE -
LOG(UNDO) -
|
Note: Still ')' is present after parameter INDEXED.
Expected Output:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED -
RLSQUIESCE -
LOG(UNDO) -
|
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
spizen556 wrote: |
Hello sergeyken,
If any of the below parameters are not present then need to find for keyword Keys and add the required parameters.
NONINDEXED,
NIXD,
INDEXED,
IXD,
NUMBERED,
NUMD
To overcome this scenarios i have added "Keyp?" & "Defines?" to your code.
|
You are right.
My intention was not to give a ready-to-copy-and-paste code, but to give an idea to the TS how to properly resolve his issue?
The further minor details of the code are supposed to be moved to the Beginners Forum. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
sergeyken wrote: |
spizen556 wrote: |
Hello sergeyken,
If any of the below parameters are not present then need to find for keyword Keys and add the required parameters.
NONINDEXED,
NIXD,
INDEXED,
IXD,
NUMBERED,
NUMD
To overcome this scenarios i have added "Keyp?" & "Defines?" to your code.
|
You are right.
My intention was not to give a ready-to-copy-and-paste code, but to give an idea to the TS how to properly resolve his issue?
The further minor details of the code are supposed to be moved to the Beginners Forum. |
Thank you sergeyken.
1. When there is space between Keys and '(" ex: "KEYS (09 00)" . ==> This issue is resolved by added or statement to the existing one as below.
Code: |
Keysp? = Pos( ' KEYS', LINE ) > 0,
| Pos( ' KEYS ', LINE ) > 0
|
Please correct me if i'm wrong.
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED) ==> Still this is pending.
I don't have any simple idea to solve this. Please help if you have any suggestion.
The idea what i have is ,
Index1? = Pos( ' INDEXED)', LINE ) > 0 ,
| Pos( ' IXD)', LINE ) > 0
For all the other parameters i need to add ')' also and add another paragraph to add the parameters before that line. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
spizen556 wrote: |
1. When there is space between Keys and '(" ex: "KEYS (09 00)" . ==> This issue is resolved by added or statement to the existing one as below.
Code: |
Keysp? = Pos( ' KEYS', LINE ) > 0,
| Pos( ' KEYS ', LINE ) > 0
|
Please correct me if i'm wrong.
|
There is no need to check both cases; the first POS detects both of them, and there is a very low chance some other cases might fall into this simple check mistakenly; I do not re-call those. If they do exist, we might need to check them more specifically.
spizen556 wrote: |
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED) ==> Still this is pending.
I don't have any simple idea to solve this. Please help if you have any suggestion.
The idea what i have is ,
Index1? = Pos( ' INDEXED)', LINE ) > 0 ,
| Pos( ' IXD)', LINE ) > 0
For all the other parameters i need to add ')' also and add another paragraph to add the parameters before that line. |
The same story: any test via POS on ' STRING' is enough to verify all cases:
Code: |
' STRING'
' STRING '
' STRING)'
' STRING )' |
and many other combinations, too.
No need to check for optional parenthesis, commas, or whatever else.
We may rely on reasonably correct source syntax; no need to create sophisticated syntax parser to be able to parse any possible garbage.
P.S.
If comments are allowed within /* and */, it makes sense just to exclude that parts from LINE before verification on all other keywords under question. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
I would have gone for a completely different approach
instead of pattern matching better IMO do carry on a proper parsing
it opens lots more of possibilities to customize the input
here is my approach
beware ...
disregard the EXECIO format
I tested on my pc using object rexx ....
the code part should run nicely also on TSO
just take care of the not and concatenation operators
it just assumes that the idcams statements are in the SYSIN. stem
just add more keywords and flags id needed
I just filled the ones needed to process the posted scenarios
the rexx script
Code: |
#! /usr/bin/env rexx
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
idckwds = "NAME CISZ CYL CYLINDERS FREESPACE KEYS LOG RECORDSIZE RECSZ SHR VOLUMES"
idcflgs = "INDEXED NOERASE NOIMBED NOREUSE NOWRITECHECK RSLQUIESCE SPEED UNORDERED "
address hostemu "execio * diskr idcedit.data (finis stem sysin."
stmt = ""
do isys = 1 to sysin.0
card = sysin.isys
if stmt = "" then do
if left(space(card),6) \= "DEFINE" then ,
iterate
else ,
stmt = space( card )
end
else do
stmt = space( stmt card )
end
if right(stmt,1) = "-" then do
stmt = strip(stmt, "T", "-")
iterate
end
stmt_new = ""
do i = 1 to length(stmt)
tk = substr(stmt,i,1)
select
when tk = "(" then ,
stmt_new = stmt_new " ( "
when substr(stmt,i,1) = ")" then ,
stmt_new = stmt_new " ) "
otherwise ,
stmt_new = stmt_new || tk
end
end
stmt = space( stmt_new )
CLUSTER.RSLQUIESCE = ""
CLUSTER.LOG = "( UNDO )"
do while stmt \= ""
parse var stmt tk .
tk = space(tk)
if tk = ")" then do
/* build the reformatted idcams statements
for CLUSTER AIX DATA INDEX
*/
if wordpos(comp, "CLUSTER AIX PATH" ) > 0 then do
say "/* */"
say " DEFINE "comp" ( -"
end
else do
say " "comp" ( -"
end
do k = 1 to words(idckwds idcflgs)
kw = word(idckwds idcflgs, k)
if symbol( comp"."kw ) = "VAR" then do
interpret "say ' '"kw" "comp"."kw"' -'"
interpret drop comp"."kw
end
end
parse var stmt . stmt
comp = ""
if stmt = "" then do
say " )"
end
else do
say " ) -"
end
iterate
end
if tk = "(" then do
parse var stmt "(" kval ")" stmt
kval = space(kval)
stmt = space(stmt)
interpret comp"."keyw"=" "'( "kval" )'"
iterate
end
if tk = "DEFINE" then do
parse var stmt . stmt
stmt = space(stmt)
iterate
end
if wordpos( tk, "CLUSTER AIX PATH DATA INDEX" ) > 0 then do
/* lookahead one symbol to discard the open parenthesis */
parse var stmt . stmt
comp = tk
parse var stmt tk .
tk = space(tk)
if tk \= "(" then ,
signal logic_error
parse var stmt . stmt
stmt = space(stmt)
iterate
end
keyw = space(tk)
if wordpos(keyw, idcflgs ) > 0 then ,
interpret comp"."keyw"=" "''"
parse var stmt . stmt
stmt = space(stmt)
end
end
exit
::requires "hostemu" LIBRARY
|
the input
Code: |
DEFINE CLUSTER ( -
NAME(FILE.NAME1) -
CYLINDERS(200 200) -
KEYS(10 0) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( -
NAME(FILE.NAME1.DATA) -
VOLUMES(A ) -
CISZ(4096) -
RECORDSIZE(60 60) -
)
DEFINE CLUSTER -
(NAME(FILE.NAME2) -
SHR(2 3) -
KEYS(14 0) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
DATA -
(NAME(FILE.NAME2.DATA) -
CISZ(4096) -
CYL(500 50) -
RECORDSIZE(150 150) -
VOLUMES(A )) -
INDEX -
(NAME(FILE.NAME2.INDEX) -
NOIMBED -
VOLUMES(I ) )
DEFINE CLUSTER ( -
NAME(FILE.NAME3) -
CYL(300 50) -
INDEXED -
NOREUSE -
NOWRITECHECK -
SHR (2 3) -
UNORDERED -
) -
DATA ( -
NAME(FILE.NAME3.DATA) -
VOLUMES(A ) -
CONTROLINTERVALSIZE(4096) -
FREESPACE(20 20) -
KEYS(18 0) -
NOERASE -
RECORDSIZE(1020 1020) -
SPEED -
)
|
the result
Code: |
/* */
DEFINE CLUSTER ( -
NAME ( FILE.NAME1 ) -
CYLINDERS ( 200 200 ) -
FREESPACE ( 25 10 ) -
KEYS ( 10 0 ) -
LOG ( UNDO ) -
SHR ( 3 3 ) -
RSLQUIESCE -
) -
DATA ( -
NAME ( FILE.NAME1.DATA ) -
CISZ ( 4096 ) -
RECORDSIZE ( 60 60 ) -
VOLUMES ( A ) -
)
/* */
DEFINE CLUSTER ( -
NAME ( FILE.NAME2 ) -
FREESPACE ( 10 5 ) -
KEYS ( 14 0 ) -
LOG ( UNDO ) -
RECSZ ( 150 150 ) -
SHR ( 2 3 ) -
INDEXED -
RSLQUIESCE -
) -
DATA ( -
NAME ( FILE.NAME2.DATA ) -
CISZ ( 4096 ) -
CYL ( 500 50 ) -
RECORDSIZE ( 150 150 ) -
VOLUMES ( A ) -
) -
INDEX ( -
NAME ( FILE.NAME2.INDEX ) -
VOLUMES ( I ) -
NOIMBED -
)
/* */
DEFINE CLUSTER ( -
NAME ( FILE.NAME3 ) -
CYL ( 300 50 ) -
LOG ( UNDO ) -
SHR ( 2 3 ) -
INDEXED -
NOREUSE -
NOWRITECHECK -
RSLQUIESCE -
UNORDERED -
) -
DATA ( -
NAME ( FILE.NAME3.DATA ) -
FREESPACE ( 20 20 ) -
KEYS ( 18 0 ) -
RECORDSIZE ( 1020 1020 ) -
VOLUMES ( A ) -
NOERASE -
SPEED -
)
|
|
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
oops..
I did not notice that the new attributes are only to be added on some conditions
the change to my script is not that complicated
instead an unconditional setting
Code: |
CLUSTER.RSLQUIESCE = ""
CLUSTER.LOG = "( UNDO )"
do while stmt \= ""
parse var stmt tk .
tk = space(tk)
if tk = ")" then do
/* build the reformatted idcams statements
for CLUSTER AIX DATA INDEX
*/ |
when the the closing parenthesis for the CLUSTER DEFINE is found
add a test if the appropriate keyword are there
Code: |
if tk = ")" then do
if symbol( CLUSTER.NONINDEXED ) = "VAR" | ,
symbol( CLUSTER.keyw2 ) = "VAR" | ,
. . .
symbol( CLUSTER.keywn ) = "VAR" then do
CLUSTER.RSLQUIESCE = ""
CLUSTER.LOG = "( UNDO )"
end
|
|
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Thanks for your help enrico-sorichetti.
There are lot of other scenarios as well but the code which was provided by me is working fine except the three scenarios which I have mentioned in my initial post.
I will test this code and let you know the outcome.
My only concern here is, in above code there are hardcoded keywords idckwds, idcflgs but for the VSAM cluster there are few more attributes also. My examples might have covered only few Keywords. I'm not sure if we need to incorporate all keywords here.
Just want to provide more clarification on the requirement.
The overall requirement is to add RSLQUIESCE & LOG attributes to the existing parm cards.
1. Only ESDS(Nonindexed) log parameter should be LOG(NONE) and for remaining all types of files log parameter should be LOG(UNDO).
2. RSLQUIESCE should be added for all kind of files.
Thanks once again for your help. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
Quote: |
in above code there are hardcoded keywords idckwds, idcflgs |
they were hardcoded to make the parsing easier and more understandable
the parsing for a flag is complete when the script sees the flag
the parsing for a keyword with arguments is complete only after the next entity has been processed ( one lookahead )
anyway it is useful to hardcode some keywords/flags because the table will give the sequence in which the keyword are generated |
|
Back to top |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2608 Location: Silicon Valley
|
|
|
|
re: handling comments:
Code: |
IF SUBSTR(LINE,1,3) = "//*" | SUBSTR(LINE,1,3) = " /*" THEN ITERATE |
This assumes the comment is left justified... I recall that the comment can appear in any column and even be to the right of command keywords.
For example:
Code: |
/* DEFINE a new cluster */
DEFINE CLUSTER ( /* test utility */ -
NAME(FILE.NAME1) -
CYLINDERS(200 200) -
KEYS(10 0) -
FREESPACE (25 10) -
SHR(3 3) -
) -
DATA ( /* more tests */ -
NAME(FILE.NAME1.DATA) -
VOLUMES(A ) -
CISZ(4096) -
RECORDSIZE(60 60) -
) |
FYI. I am retired and could not actually verify if my recollection was correct. |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
@Pedro: Your comment about comments is still valid. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
enrico-sorichetti wrote: |
oops..
I did not notice that the new attributes are only to be added on some conditions
the change to my script is not that complicated
instead an unconditional setting
Code: |
CLUSTER.RSLQUIESCE = ""
CLUSTER.LOG = "( UNDO )"
do while stmt \= ""
parse var stmt tk .
tk = space(tk)
if tk = ")" then do
/* build the reformatted idcams statements
for CLUSTER AIX DATA INDEX
*/ |
when the the closing parenthesis for the CLUSTER DEFINE is found
add a test if the appropriate keyword are there
Code: |
if tk = ")" then do
if symbol( CLUSTER.NONINDEXED ) = "VAR" | ,
symbol( CLUSTER.keyw2 ) = "VAR" | ,
. . .
symbol( CLUSTER.keywn ) = "VAR" then do
CLUSTER.RSLQUIESCE = ""
CLUSTER.LOG = "( UNDO )"
end
|
|
Hi Enrico,
I just copy & paste your code and tested. I have two files in input but output is one file.
I also tested with around 10 files and even here the output is 4 or 5 files.
Input:
Code: |
000001 DELETE FILE.NAME1 PURGE
000002 IF LASTCC > 0 THEN SET MAXCC = 0
000003 DEFINE CLUSTER ( NAME (FILE.NAME1) -
000004 CYL (200 10) -
000005 RECSZ (1200 1500) -
000006 SHR (2 3) -
000007 NONINDEXED -
000008 SPEED )-
000009 DATA ( NAME (FILE.NAME1.DATA) -
000010 VOLUME (A ) )
000011
000012 DELETE (FILE.NAME2) PURGE CLUSTER
000013
000014 SET LASTCC=0
000015 SET MAXCC=0
000016
000017 DEFINE CLUSTER ( -
000018 NAME(FILE.NAME2) -
000019 CYLINDERS(200 200) -
000020 KEYS(10 0) -
000021 FREESPACE (25 10) -
000022 SHR(3 3) -
000023 ) -
000024 DATA ( -
000025 NAME(FILE.NAME2.DATA) -
000026 VOLUMES(A )) -
000027 CISZ(4096) -
000028 RECORDSIZE(60 60) -
000029 )
|
Output:
Code: |
/* */
DEFINE CLUSTER ( -
NAME ( FILE.NAME1 ) -
CYL ( 200 10 ) -
LOG ( UNDO ) -
RECSZ ( 1200 1500 ) -
SHR ( 2 3 ) -
RSLQUIESCE -
SPEED -
) -
DATA ( -
NAME ( FILE.NAME1.DATA ) -
)
***
|
If you don't mind, Could you please help me to the code which i provided. That helps me a lot.
Thanks in advance. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
spizen556 wrote: |
Hello sergeyken,
If any of the below parameters are not present then need to find for keyword Keys and add the required parameters.
NONINDEXED,
NIXD,
INDEXED,
IXD,
NUMBERED,
NUMD
To overcome this scenarios i have added "Keyp?" & "Defines?" to your code.
Code: |
Defines? = Pos( ' DEFINE', LINE ) > 0
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0
Number? = Pos( ' NUMBERED', LINE ) > 0 ,
| Pos( ' NUMD', LINE ) > 0
Keysp? = Pos( ' KEYS', LINE ) > 0
. . . . . . . . . . . . .
SELECT
WHEN Defines? THEN DO
ADDPERM = 'N'
END
WHEN NoIndex? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Index? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Number? & ADDPERM = 'N' THEN DO
PRMT3 = "LOG(UNDO)"||' '||"-"
P1=POS(VAR1,LINE)
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
WHEN Keysp? & ADDPERM = 'N' THEN DO
ATTR3 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRIBUTES
ADDPERM = 'Y'
END
. . . . . . . . .
|
It's adding parameters in below scenarios:
1. When there is space between Keys and '(" ex: "KEYS (09 00)" .
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED)
Input:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
|
Output:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED) -
RLSQUIESCE -
LOG(UNDO) -
|
Note: Still ')' is present after parameter INDEXED.
Expected Output:
Code: |
SHR (2 3) -
FREESPACE(10 5) -
RECSZ(150 150) -
INDEXED -
RLSQUIESCE -
LOG(UNDO) -
|
|
I tested lot of scenarios and it is working fine except the below scenario.
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED).
More details are provide in above post.
I'm not able to fix this issue.
Code: |
ADDRESS ISREDIT
"MACRO"
ADDRESS ISREDIT
STRINGA= 'INDEXED' || 'IXD' || 'NUMBERED' || 'NUMD'
STRINGB= 'NONINDEXED' || 'NIXD'
ADDMODL = 0
ADDATTR = 'N'
"(CURRLN) = LINENUM .ZCSR" /* CURRENT LINE */
"(LASTLN) = LINENUM .ZLAST" /* LAST LINE NUMBER */
I = 0
DO FOREVER
I = I + 1
IF I > LASTLN THEN LEAVE
"(LINE) = LINE " I
LINE = SUBSTR(LINE,1,80)
IF SUBSTR(LINE,1,3) = "//*" | SUBSTR(LINE,1,3) = " /*" THEN ITERATE
VAR1 = SUBWORD(LINE,1,1)
UPPER VAR1
PRMT1 = "RLSQUIESCE"||' '||"-"
Defines? = Pos( ' DEFINE', LINE ) > 0,
| Pos( ' DEFINE ', LINE ) > 0
stringa? = Pos( ' STRINGA', LINE ) > 0,
| Pos( ' STRINGA ', LINE ) > 0,
| Pos( ' STRINGA)', LINE ) > 0,
| Pos( ' STRINGA )', LINE ) > 0
stringb? = Pos( ' STRINGb', LINE ) > 0,
| Pos( ' STRINGb ', LINE ) > 0,
| Pos( ' STRINGb)', LINE ) > 0,
| Pos( ' STRINGb )', LINE ) > 0
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0
Number? = Pos( ' NUMBERED', LINE ) > 0 ,
| Pos( ' NUMD', LINE ) > 0
Keysp? = Pos( ' KEYS', LINE ) > 0,
| Pos( ' KEYS ', LINE ) > 0
SELECT
WHEN Defines? THEN DO
ADDATTR = 'N'
END
WHEN stringa? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRB
ADDATTR = 'Y'
END
WHEN stringb? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRB
ADDATTR = 'Y'
END
WHEN NoIndex? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(NONE)"||' '||"-"
CALL ADD_ATTRA
ADDATTR = 'Y'
END
WHEN Index? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRA
ADDATTR = 'Y'
END
WHEN Number? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRA
ADDATTR = 'Y'
END
WHEN Keysp? & ADDATTR = 'N' THEN DO
PRMT2 = "LOG(UNDO)"||' '||"-"
CALL ADD_ATTRA
ADDATTR = 'Y'
END
OTHERWISE
NOP
END
END
/* EXIT(RC) */
EXIT 0
/* ------------------------------------------------------------ */
ADD_ATTRA:
/* ------------------------------------------------------------ */
ADDRESS ISREDIT
ADDMODL = 1
LN = I
SAY ' LN : ' LN
P1=POS(VAR1,LINE)
"ISREDIT LINE_AFTER " LN "= DATALINE '" PRMT1"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
"ISREDIT LINE_AFTER " LN "= DATALINE '" PRMT2"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
RETURN
/* ------------------------------------------------------------ */
ADD_ATTRB:
/* ------------------------------------------------------------ */
ADDRESS ISREDIT
ADDMODL = 1
LN = I
SAY ' LN : ' LN
P1=POS(VAR1,LINE)
"ISREDIT LINE_BEFORE " LN "= DATALINE '" PRMT1"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
"ISREDIT LINE_BEFORE " LN "= DATALINE '" PRMT2"'"
LN = LN + 1
LASTLN = LASTLN + 1
"ISREDIT SHIFT ) " LN P1-2
RETURN
|
|
|
Back to top |
|
 |
prino
Senior Member

Joined: 07 Feb 2009 Posts: 1318 Location: Vilnius, Lithuania
|
|
|
|
Code: |
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0 |
So every time you set NoIndex? you also set Index? SIASD! |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
prino wrote: |
Code: |
NoIndex? = Pos( ' NONINDEXED', LINE ) > 0 ,
| Pos( ' NIXD', LINE ) > 0
Index? = Pos( ' INDEXED', LINE ) > 0 ,
| Pos( ' IXD', LINE ) > 0 |
So every time you set NoIndex? you also set Index? SIASD! |
The flags are used ONLY to indicate the presence of each specific keyword in the current line.
Alternate way is - explicit reset of all flags before every new line, and/or conditional verification of each flag depending on those previously set.
This approach would be really SIASD - if only you thought a little about this. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
[quote="spizen556"]
spizen556 wrote: |
I tested lot of scenarios and it is working fine except the below scenario.
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED).
More details are provide in above post.
I'm not able to fix this issue. |
The most primitive fix is: insert your new line(s) not after, but before the current line; either it ends with ')' or not.
The whole REXX code could also be re-arranged in a more simple and clear way; I'm busy now for this exercise. Maybe later I'll return to it. |
|
Back to top |
|
 |
spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
[quote="sergeyken"]
spizen556 wrote: |
spizen556 wrote: |
I tested lot of scenarios and it is working fine except the below scenario.
2. If parameter is ending with ')' i.e., last parameter ex: INDEXED).
More details are provide in above post.
I'm not able to fix this issue. |
The most primitive fix is: insert your new line(s) not after, but before the current line; either it ends with ')' or not.
The whole REXX code could also be re-arranged in a more simple and clear way; I'm busy now for this exercise. Maybe later I'll return to it. |
I tried to add before but my code is overwriting. I will try again and post the results.
I also will test with trace option and try to figure out.
I can understand. Thanks for your time and help. |
|
Back to top |
|
 |
|
|