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

Adding a label to lines based on a condition


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Mon Mar 02, 2009 1:16 pm
Reply with quote

Hi,
Is it possible to add a label to the lines of a program based on a condition?
My requirement is to display "==MSG>" when ever I encounter an error, say a DISPLAY statement in a Cobol program.
But it would be difficult to go and check the entire program for messages. So, I want to add lables to the lines where ever I encounter an error in the program, with lable name as '.ErrAA', '.ErrAB', '.ErrAC' and so on.

Is this possible to do using REXX.

Regards,
Balu
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Mar 02, 2009 1:58 pm
Reply with quote

First of all, it is possible to go to MSG lines by using "LOC MSGLINE",
but I this command is not well known, and there is no shortcut (LOC MSG would be OK, but it doesn't work!).

Anyway, to set a label on cursor line, use:
Code:
MyLabel = 'AA'
Address ISREDIT 'LABEL .ZCSR = .Err'MyLabel' 0'
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Mar 02, 2009 2:28 pm
Reply with quote

To increment the label letters, I would code:
Code:
/* One time init */
LblLst = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Lbl1 = 1
Lbl2 = 0
.
.
.
/* place label on line */
'LABEL .ZCSR = .Err'MakeLabel()' 0'

The MakeLabel function is:
Code:
MakeLabel:                                               
   Lbl2 = Lbl2 + 1                                       
   If Lbl2 > 26 Then Do                                 
      Lbl1 = Lbl1 + 1                                   
      Lbl2 = 1                                           
   End                                                   
   MyLbl = Substr(LblLst,Lbl1,1) || Substr(LblLst,Lbl2,1)
Return MyLbl

It should work from AA to ZZ!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Mar 02, 2009 3:08 pm
Reply with quote

Marso wrote:
It should work from AA to ZZ!
".ZZ" labels are invalid - are not they?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Mar 02, 2009 3:55 pm
Reply with quote

True! but it's still OK as they are prefixed
(should have said from ErrAA to ErrZZ) icon_wink.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Mar 02, 2009 4:14 pm
Reply with quote

oh..o o.., yup you are right... icon_smile.gif.
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Mon Mar 02, 2009 5:03 pm
Reply with quote

Thanks for all your effort in giving various solutions. I have your codes and they are working fine.
I just wanted to know how we can add the label to a line based on line no instead of adding to the current cursour position line.
Why because
I have coded like
Code:

NDX1 = NDX1 + 1               
'ISREDIT (KLINE) = LINE ' NDX1

to extract each line of the program and check for error in KLINE
and display a message like this:
Code:

'ISREDIT LINE_BEFORE' NDX1 '= MSGLINE' ERROR_MSG

Just similar to this I need the label in line NDX1
so, I have tried giving
Code:

ADDRESS ISREDIT 'LABEL LINE ' NDX1 ' = .ER'MYLABEL' 0'

But this is not working.
Please help me...
I have another doubt
what is use of ' 0' in the above statement?
Regards,
Balu
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Mar 02, 2009 6:24 pm
Reply with quote

I have only one macro that sets labels on cursor lines,
so I had to look at the book. It says that works:
Code:
ADDRESS ISREDIT 'LABEL ' NDX1 ' = .ER'MYLABEL' 0'


The '0' is the level. It's optional. I turn again to the book:
Quote:
level The highest nesting level at which this label is visible to you or to a macro. Level 0 is the highest level. Labels at this level are visible to
you and to all levels of nested macros. Level 1 is not visible to you, but it is visible to all macros, and so on. The level can never exceed
the current nesting level. The maximum nesting level is 255. The level number defaults to the current nesting level.
Maybe one day I will have use for hidden labels. Until then I'll keep putting 0...
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Mon Mar 02, 2009 6:47 pm
Reply with quote

Thanks Marso! Its working!!

Regards,
Balu
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Mar 02, 2009 9:10 pm
Reply with quote

My pleasure !
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 -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Adding first / last acct numerber to ... DFSORT/ICETOOL 7
No new posts Adding 'ODD' and 'EVEN' indicator at ... DFSORT/ICETOOL 6
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top