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

Rexx code to find greater then symobl ">" in a cobol program


IBM Mainframe Forums -> CLIST & REXX
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Bharath Vikraman

New User


Joined: 06 Aug 2017
Posts: 9
Location: India

PostPosted: Tue May 29, 2018 9:40 am
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue May 29, 2018 11:44 am
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Tue May 29, 2018 12:28 pm
Reply with quote

And which PHB came up with this, frankly imbecile, "requirement"?
Back to top
View user's profile Send private message
Bharath Vikraman

New User


Joined: 06 Aug 2017
Posts: 9
Location: India

PostPosted: Tue May 29, 2018 12:51 pm
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Tue May 29, 2018 1:29 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue May 29, 2018 4:38 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed May 30, 2018 3:44 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed May 30, 2018 6:46 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 30, 2018 7:52 pm
Reply with quote

Have to agree with Prino ......................... LOCKED
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top