IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

New Parameter should be added to the existing parm thru REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Apr 07, 2020 5:23 pm
Reply with quote

Code:
000026            VOLUMES(A )) -

is wrong, only one closed parenthesis

Yo will need to add VOLUME and NONINDEXED to the keyword list

I just cut and pasted Your data and after the two mods I told above
I got

Code:

/* */
   DEFINE CLUSTER ( -
          NAME ( FILE.NAME1 ) -
          CYL ( 200 10 ) -
          LOG ( UNDO ) -
          RECSZ ( 1200 1500 ) -
          SHR ( 2 3 ) -
          NONINDEXED  -
          RSLQUIESCE  -
          SPEED  -
          ) -
          DATA ( -
          NAME ( FILE.NAME1.DATA ) -
          VOLUME ( A ) -
          )
/* */
   DEFINE CLUSTER ( -
          NAME ( FILE.NAME2 ) -
          CYLINDERS ( 200 200 ) -
          FREESPACE ( 25 10 ) -
          KEYS ( 10 0 ) -
          LOG ( UNDO ) -
          SHR ( 3 3 ) -
          RSLQUIESCE  -
          ) -
          DATA ( -
          NAME ( FILE.NAME2.DATA ) -
          CISZ ( 4096 ) -
          RECORDSIZE ( 60 60 ) -
          VOLUMES ( A ) -
          )
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Tue Apr 07, 2020 8:55 pm
Reply with quote

spizen556 wrote:
sergeyken wrote:

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.


I spent about 40 minutes to fix the bugs, to adjust the style of coding, and to remove absolutely unneeded garbage from the code.

It seems to be working correctly.

I am against using too complicated methods to reach simple goals, that's why I always do everything in the most simple way.
Code:
/* REXX */                                                             
Address ISREDIT                                                         
"MACRO"                                                                 
                                                                       
 "(CURRLN) = LINENUM .ZCSR"            /* CURRENT LINE           */     
 "(LASTLN) = LINENUM .ZLAST"           /* LAST LINE NUMBER       */     
 I = 0                                                                 
 Defines? = 0                                                           
 AttrAdded? = 0                                                         
 Do Forever                                                             
    I = I + 1                                                           
    If I > LASTLN Then Leave           /* stop at the end of text */   
    "(LINE)  = LINE " I                /* read whole line */           
                                                                       
    Parse Var Line Line '/*' Comments   /* separate comment part */     
    If Line = '' Then                   /* nothing but comments? */     
       Iterate                          /* continue to next line */     
                                                                       
    If ¬Defines? Then Do                /* look for first DEFINE */     
       Defines? = Pos( ' DEFINE', LINE ) > 0 /* mark "DEFINE clause" */
       If Defines? Then                                                 
          AttrAdded? = 0          /* reset flag when first in DEFINE */
    End                                                                 
    Else If Pos( ' DATA', LINE ) > 0 Then /* look for end DEFINE */     
       Defines? = 0                     /* mark "out of DEFINE clause */
                                                                       
    If ¬Defines? ,                      /* while not within DEFINE */   
     | AttrAdded? Then                  /* or all done already */       
       Iterate                          /* continue to next line */     
                                                                       
    /* Detect all keywords we are interested in */                     
    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 NoIndex? Then                                                 
         CALL ADD_ATTRB I "LOG(NONE) -"                                 
                                                                       
    When Index?   ,                                                     
       | Number?  ,                                                     
       | Keysp?   Then                                                 
         CALL ADD_ATTRB I "LOG(UNDO) -"                                 
                                                                       
    Otherwise                                                           
       Nop                                                             
    End                                                                 
 End                                                                   
                                                                       
 Return 0                                                               
                                                                       
 /* ------------------------------------------------------------ */     
 ADD_ATTRB:                                                             
 /* ------------------------------------------------------------ */     
 Arg LN PRMT2             /* variable parts passed as parameters */     
                                                                       
    Address ISREDIT                                                     
    PRMT1 = "RLSQUIESCE -"    /* constant part defined as local */     
                                                                       
    P1 = Verify( LINE, ' ' )        /* calculate current indentation */
    Blanks = Copies( ' ', P1 - 2 )  /* prepare string of blanks */     
    "ISREDIT LINE_BEFORE " LN "= DATALINE '" Blanks || PRMT1"'"         
    "ISREDIT LINE_BEFORE " LN "= DATALINE '" Blanks || PRMT2"'"         
    LASTLN = LASTLN + 2     /* new last line now moved by 2 */         
    AttrAdded? = 1          /* flag "this clause done" */               
 Return                                                                 


I hope when more special cases need to be considered, it would be much easier to update a short and clear code, rather than a sophisticated and long one.
Back to top
View user's profile Send private message
spizen556

New User


Joined: 02 Apr 2020
Posts: 14
Location: India

PostPosted: Wed Apr 08, 2020 3:56 pm
Reply with quote

sergeyken wrote:
spizen556 wrote:
sergeyken wrote:

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.


I spent about 40 minutes to fix the bugs, to adjust the style of coding, and to remove absolutely unneeded garbage from the code.

It seems to be working correctly.

I am against using too complicated methods to reach simple goals, that's why I always do everything in the most simple way.
Code:
/* REXX */                                                             
Address ISREDIT                                                         
"MACRO"                                                                 
                                                                       
 "(CURRLN) = LINENUM .ZCSR"            /* CURRENT LINE           */     
 "(LASTLN) = LINENUM .ZLAST"           /* LAST LINE NUMBER       */     
 I = 0                                                                 
 Defines? = 0                                                           
 AttrAdded? = 0                                                         
 Do Forever                                                             
    I = I + 1                                                           
    If I > LASTLN Then Leave           /* stop at the end of text */   
    "(LINE)  = LINE " I                /* read whole line */           
                                                                       
    Parse Var Line Line '/*' Comments   /* separate comment part */     
    If Line = '' Then                   /* nothing but comments? */     
       Iterate                          /* continue to next line */     
                                                                       
    If ¬Defines? Then Do                /* look for first DEFINE */     
       Defines? = Pos( ' DEFINE', LINE ) > 0 /* mark "DEFINE clause" */
       If Defines? Then                                                 
          AttrAdded? = 0          /* reset flag when first in DEFINE */
    End                                                                 
    Else If Pos( ' DATA', LINE ) > 0 Then /* look for end DEFINE */     
       Defines? = 0                     /* mark "out of DEFINE clause */
                                                                       
    If ¬Defines? ,                      /* while not within DEFINE */   
     | AttrAdded? Then                  /* or all done already */       
       Iterate                          /* continue to next line */     
                                                                       
    /* Detect all keywords we are interested in */                     
    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 NoIndex? Then                                                 
         CALL ADD_ATTRB I "LOG(NONE) -"                                 
                                                                       
    When Index?   ,                                                     
       | Number?  ,                                                     
       | Keysp?   Then                                                 
         CALL ADD_ATTRB I "LOG(UNDO) -"                                 
                                                                       
    Otherwise                                                           
       Nop                                                             
    End                                                                 
 End                                                                   
                                                                       
 Return 0                                                               
                                                                       
 /* ------------------------------------------------------------ */     
 ADD_ATTRB:                                                             
 /* ------------------------------------------------------------ */     
 Arg LN PRMT2             /* variable parts passed as parameters */     
                                                                       
    Address ISREDIT                                                     
    PRMT1 = "RLSQUIESCE -"    /* constant part defined as local */     
                                                                       
    P1 = Verify( LINE, ' ' )        /* calculate current indentation */
    Blanks = Copies( ' ', P1 - 2 )  /* prepare string of blanks */     
    "ISREDIT LINE_BEFORE " LN "= DATALINE '" Blanks || PRMT1"'"         
    "ISREDIT LINE_BEFORE " LN "= DATALINE '" Blanks || PRMT2"'"         
    LASTLN = LASTLN + 2     /* new last line now moved by 2 */         
    AttrAdded? = 1          /* flag "this clause done" */               
 Return                                                                 


I hope when more special cases need to be considered, it would be much easier to update a short and clear code, rather than a sophisticated and long one.



I am so thankful for what you did.

I just added one more line since i saw some statement "DEF CLUSTER" instead of DEFINE CLUSTER.

Code:

Defines? = Pos( ' DEFINE', LINE ) > 0,
         | Pos( ' DEF ',   LINE ) > 0



Thanks again for helping me with this requirement.
Back to top
View user's profile Send private message
spizen556

New User


Joined: 02 Apr 2020
Posts: 14
Location: India

PostPosted: Wed Apr 08, 2020 7:02 pm
Reply with quote

enrico-sorichetti wrote:
Code:
000026            VOLUMES(A )) -

is wrong, only one closed parenthesis

Yo will need to add VOLUME and NONINDEXED to the keyword list

I just cut and pasted Your data and after the two mods I told above
I got

Code:

/* */
   DEFINE CLUSTER ( -
          NAME ( FILE.NAME1 ) -
          CYL ( 200 10 ) -
          LOG ( UNDO ) -
          RECSZ ( 1200 1500 ) -
          SHR ( 2 3 ) -
          NONINDEXED  -
          RSLQUIESCE  -
          SPEED  -
          ) -
          DATA ( -
          NAME ( FILE.NAME1.DATA ) -
          VOLUME ( A ) -
          )
/* */
   DEFINE CLUSTER ( -
          NAME ( FILE.NAME2 ) -
          CYLINDERS ( 200 200 ) -
          FREESPACE ( 25 10 ) -
          KEYS ( 10 0 ) -
          LOG ( UNDO ) -
          SHR ( 3 3 ) -
          RSLQUIESCE  -
          ) -
          DATA ( -
          NAME ( FILE.NAME2.DATA ) -
          CISZ ( 4096 ) -
          RECORDSIZE ( 60 60 ) -
          VOLUMES ( A ) -
          )


Thanks a lot Enrico for your valuable time and help on this.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Thu Apr 09, 2020 9:20 pm
Reply with quote

Some more notes.

1) The alternate solution is supposed mainly to resolve another issue: standardized alignment/arrangement of the source statement(s). Logically it is a separate task from adding missing parameters. Those two could be implemented separately from each other, and also applied separately, which makes sense in most cases.

2) Partial syntax check algorithm could be implemented in a less chaotic way, by using the existing REXX operations. Long time ago I did such exercises; maybe I'll present some parsing examples in a separate topic.

3) In all presented examples we did not consider important case(s): what if the parameters to be added do exist already in the source code? (For instance, if this macro has been applied twice to the same library member???)
This case is much more important than re-alignment of the source code, but it requires a changed scan/parse approach.
Back to top
View user's profile Send private message
spizen556

New User


Joined: 02 Apr 2020
Posts: 14
Location: India

PostPosted: Fri Apr 10, 2020 2:55 pm
Reply with quote

sergeyken wrote:
Some more notes.

1) The alternate solution is supposed mainly to resolve another issue: standardized alignment/arrangement of the source statement(s). Logically it is a separate task from adding missing parameters. Those two could be implemented separately from each other, and also applied separately, which makes sense in most cases.

2) Partial syntax check algorithm could be implemented in a less chaotic way, by using the existing REXX operations. Long time ago I did such exercises; maybe I'll present some parsing examples in a separate topic.

3) In all presented examples we did not consider important case(s): what if the parameters to be added do exist already in the source code? (For instance, if this macro has been applied twice to the same library member???)
This case is much more important than re-alignment of the source code, but it requires a changed scan/parse approach.


Thanks for your suggestions and which are valid scenarios.

I already faced the similar example with respect to your third point.

Some other team already added these parameters couple of months ago but by mistakenly client had given same members to us again.

currently we are doing srchfor with keyword in the PDS before running this rexx code.

My idea is to find for string "RSLQUIESCE" and the logic if found.

I will post the logic here if i'm able to fix it.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top