Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REGARDING FUNCTION REVERSE...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ram_vizag

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Mon Sep 23, 2013 7:23 pm    Post subject: REGARDING FUNCTION REVERSE...
Reply with quote

Hi Friends,

Could some one please explain the follwoing code with example: i mean input and out put value.

Code:


05  TEMP-STRING                 PIC X(10).
05  TEMP-STRING-B               PIC X(10).

                                                                 
    MOVE ZERO TO TRAIL-CNTR.                                     
    INSPECT FUNCTION REVERSE (TEMP-STRING)                       
       TALLYING TRAIL-CNTR                                       
       FOR LEADING SPACES.                                       
    MOVE SPACE TO TEMP-STRING-B.                                 
    IF TRAIL-CNTR < FUNCTION LENGTH (TEMP-STRING)               
       MOVE TEMP-STRING   TO TEMP-STRING-B ((TRAIL-CNTR + 1) : )
       MOVE TEMP-STRING-B TO TEMP-STRING                         
    END-IF.                                                     
                                                                 
    INSPECT TEMP-STRING                                         
       REPLACING LEADING SPACES BY ZEROES.   

Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Sep 23, 2013 7:38 pm    Post subject:
Reply with quote

Maybe after you explain why the hell you post a COBOL question in the JCL forum icon_evil.gif

Why should someone else supply the inputs and outputs for you. Do you not have access to a mainframe to test things yourself.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Mon Sep 23, 2013 7:58 pm    Post subject:
Reply with quote

It appears to be right-justifying and left-zero-filling the data in TEMP-STRING.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Sep 23, 2013 8:11 pm    Post subject:
Reply with quote

Hello,

Suggest you make up a few test input values and see what is returned.

Break out this bit of code into a bit of code that is only to test thi function.

Post back here if there are any surprises.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Sep 23, 2013 8:18 pm    Post subject: Reply to: REGARDING FUNCTION REVERSE...
Reply with quote

Unless the input field is blank, in which case it stays blank,

Code:
    IF ( TEMP-STRING NOT EQUAL TO SPACE )
        PERFORM RIGHT-JUST-LEFT-ZERO-FILL
    END-IF

    ...

RIGHT-JUST-LEFT-ZERO-FILL.
    MOVE ZERO TO TRAIL-CNTR                                     
    INSPECT FUNCTION REVERSE (TEMP-STRING)                       
       TALLYING TRAIL-CNTR                                       
       FOR LEADING SPACES                                       
    MOVE ZERO TO TEMP-STRING-B                                 
    MOVE TEMP-STRING  TO TEMP-STRING-B ( ( TRAIL-CNTR + 1 ) : )
    MOVE TEMP-STRING-B TO TEMP-STRING     


Or:

Code:
    IF ( NO-INPUT-QUANTITY  )
        CONTINUE
    ELSE
        PERFORM RIGHT-JUST-LEFT-ZERO-FILL
    END-IF

    ...

RIGHT-JUST-LEFT-ZERO-FILL.

    MOVE ZERO TO COUNT-OF-TRAILING-BLANKS                                     

    INSPECT FUNCTION REVERSE ( INPUT-QUANTITY )                       
       TALLYING COUNT-OF-TRAILING-BLANKS                                       
       FOR LEADING SPACES                                       

    MOVE ZERO TO IQ-WITH-LEADING-ZEROS                                 

    MOVE INPUT-QUANTITY TO IQ-WITH-LEADING-ZEROS
                            ( ( COUNT-OF-TRAILING-BLANKS + 1 ) : )

    MOVE IQ-WITH-LEADING-ZEROS TO INPUT-QUANTITY     


Isn't that easier to read?

It is also easier to code and test :-)

Although I haven't this time.... asking for trouble :-)

Other ways to do it as well, of course...
Back to top
View user's profile Send private message
ram_vizag

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Tue Sep 24, 2013 2:22 pm    Post subject:
Reply with quote

expat wrote:
Maybe after you explain why the hell you post a COBOL question in the JCL forum icon_evil.gif

Why should someone else supply the inputs and outputs for you. Do you not have access to a mainframe to test things yourself.


Hi, I dont have access to test and submit a job in mainframe...thats the reason why i have posted...also if the input is __abc_____ what is output???

first two is space 3,4,5 th position is having a,b,c values respectively. and after that till 10 bytes spaces. then in this scenarion what is the output??

what will be the count of the trailer-cnt abobe 2 or 7. i mean if a string is read from back what is leading spaces in this case???

explain...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 24, 2013 4:35 pm    Post subject: Reply to: REGARDING FUNCTION REVERSE...
Reply with quote

With the original code, you'll get seven zeros then abc.

The count of the leading spaces will be five, having reversed the field, so there are five trailing spaces.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us