View previous topic :: View next topic
|
Author |
Message |
vvmanyam
New User
Joined: 16 Apr 2008 Posts: 86 Location: Bangalore
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Marso wrote: |
It should work from AA to ZZ! |
".ZZ" labels are invalid - are not they? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
True! but it's still OK as they are prefixed
(should have said from ErrAA to ErrZZ) |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
oh..o o.., yup you are right... . |
|
Back to top |
|
|
vvmanyam
New User
Joined: 16 Apr 2008 Posts: 86 Location: Bangalore
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
vvmanyam
New User
Joined: 16 Apr 2008 Posts: 86 Location: Bangalore
|
|
|
|
Thanks Marso! Its working!!
Regards,
Balu |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
My pleasure ! |
|
Back to top |
|
|
|