View previous topic :: View next topic
|
Author |
Message |
Bharath Vikraman
New User
Joined: 06 Aug 2017 Posts: 9 Location: India
|
|
|
|
Hi All,
I have an requirement to find the usage of greater than operator ( > ) in a Cobol program. So I have used a logic like -->
1) Get the starting line number of procedure division and the ending line number of the procedure division.
2) check each line for existence of ">" symbol if found print that line.
For this I have used the REXX code as -->
Code: |
count = 1 /* initialize record counter */
do while count <= input.0 /* loop through records */
after = ‘ ‘
parse UPPER var input.count . ‘>’ after
if after ^= ‘ ‘ then,
say input.count /* list the record */
count = count + 1 /* increment the record counter*/
end /* end of loop */
|
3) Now my doubt is-->
If there are some IF condition in the program like-->
If A
>
b
Here what we should do to check the previous line of the greater than symbol found if there is no any arithmetic operators or conditional expressions found before the ">" symbol in the same line?
In this case I need all the three lines to be printed.
I hope my question is clear. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
I have put your stuff into the correct code tags, see below for next time -
Code: |
[code] your stuff [/code] |
Why use REXX, why not use the built in search utility ? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1311 Location: Vilnius, Lithuania
|
|
|
|
And which PHB came up with this, frankly imbecile, "requirement"? |
|
Back to top |
|
|
Bharath Vikraman
New User
Joined: 06 Aug 2017 Posts: 9 Location: India
|
|
|
|
Thanks for the reply. Could you please let us know how we can fetch the characters from previous or next line using the search utility?? |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 724 Location: Denmark
|
|
|
|
without wanting to get into a discussion of why, here is a possible how (from the top of my head, not tested):
Code: |
do n=1 to input.0
if pos('>',input.n)=0 then iterate
if strip(input.n)='>' then do
say Value('input.'n-1)
say input.n
say Value('input.'n+1)
end
else say input.n
end
|
this assumes that a single '>' is not found in the first nor the last line. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Bharath Vikraman wrote: |
Thanks for the reply. Could you please let us know how we can fetch the characters from previous or next line using the search utility?? |
Why just the next line ???
Code: |
If
A
>
B
Then do
other code here
End
|
All you are doing is finding the occurrence of a given string.
I would guess that when a string is found some decision has to be made as to what happens within the confines of the string, or statement, which contains said occurrence, depending on the contents of that statement other options may be needed.
So to me, a quick run through at eyeball level would be the best way to start, knowing where the string occurs.
So I could suggest that on each and every occurrence you will need to flow backwards to the last code delimiter, i.e. the full stop, and then increment forward to the next delimiter.
Obviously you will need to know where exactly within the stem are so as not to encounter an "out of bounds" problem. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
What about this:
Code: |
DISPLAY 'Before something: <' DATA-IN '>'
PERFORM something
DISPLAY 'After something: <' DATA-OUT '>' |
or this:
Code: |
IF MY-NUMBER < 10 THEN
whatever
ELSE
DISPLAY 'greater than 9'
END-IF |
|
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1311 Location: Vilnius, Lithuania
|
|
|
|
Please lock this topic, the requirement is a load of bollocks!
Code: |
"isredit macro"
"isredit x all"
"isredit f '>' all"
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball
call eye_ball |
There, in a nutshell, you have the code I wrote at a former client to solve the Y2K problem. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Have to agree with Prino ......................... LOCKED |
|
Back to top |
|
|
|