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

Program logic help on building code/psudocode


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Feb 08, 2011 8:14 pm
Reply with quote

I do not speak cobolese, but whatever the language chosen
I would follow strictly the pseudo code I suggested
effective, and very easy to follow

it did not take me very long to prototype the whole thing in REXX

file1 ( the range data )
Code:

3 5
10 12
14 18


file2 ( the data )
Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


the prototype to check the logic
Code:

#! /opt/oorexx/bin/rexx

/* read the first record from the range file */
file1buff = ""
file1buff = linein("file1.txt")
/* check for an empty range file */
if  file1buff = "" then do
    /* simulate end of file */
    key1 = 9999
    key2 = 9999
end
else do
    key1 = strip(word(file1buff,1))
    key2 = strip(word(file1buff,2))
end

/* read the first record from the data file */
file2buff = ""
file2buff = linein("file2.txt")
do  forever
    /* check for end-of-file on the data file */
    if  file2buff = "" then ,
        leave
    keyd = strip(file2buff)

    /* check for the data key in the current range */
    if  key1 <= keyd & keyd <= key2 then do
        file3buff = right(keyd,4) || " in range    " right(key1,4) right(key2,4)
        say file3buff
        /* read the next record from the data file */
        file2buff = ""
        file2buff = linein("file2.txt")
        iterate
    end

    /* check for the data key below the current range */
    if  keyd < key1 then do
        file3buff = right(keyd,4) || " NOT in range"
        say file3buff
        /* read the next record from the data file */
        file2buff = ""
        file2buff = linein("file2.txt")
        iterate
    end

    /* check for the data key above the current range */
    /* not needed but prevents nasty situations       */
    if  keyd > key2 then do
        /* read the next record from the range file */
        file1buff = ""
        file1buff = linein("file1.txt")
        /* check for end-of-file on the range file */
        if  file1buff = "" then do
            key1 = 9999
            key2 = 9999
        end
        else do
            key1 = strip(word(file1buff,1))
            key2 = strip(word(file1buff,2))
        end
        iterate
    end

    say "***** Logic Error, should not be here "

end

exit


the result
Code:

   1 NOT in range
   2 NOT in range
   3 in range        3    5
   4 in range        3    5
   5 in range        3    5
   6 NOT in range
   7 NOT in range
   8 NOT in range
   9 NOT in range
  10 in range       10   12
  11 in range       10   12
  12 in range       10   12
  13 NOT in range
  14 in range       14   18
  15 in range       14   18
  16 in range       14   18
  17 in range       14   18
  18 in range       14   18
  19 NOT in range
  20 NOT in range


it did not take that long - check the posts timestamps
started doing since Your last post appeared
while waiting for a loong build to complete on my mac icon_biggrin.gif
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Feb 08, 2011 8:15 pm
Reply with quote

Perhaps the code example provided in this link could get you started in the right direction.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Feb 08, 2011 8:23 pm
Reply with quote

Hi Ronald!
getting into a self reference loop icon_biggrin.gif

if the TS had read and understood the pseudo code we would not be here!
since I was having a coffee break I prototyped the sillyness in rexx
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 -> COBOL Programming Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
Search our Forums:

Back to Top