How to display a word / name in reverse format in COBOL prog

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
Hkumar07
Member
Posts: 2
Joined: Tue Jul 17, 2012 2:09 pm

How to display a word / name in reverse format in COBOL prog

Post by Hkumar07 » Wed Jul 18, 2012 4:32 pm

How to display a word / name in reverse format in COBOL prog without using any instrinc functions.
example: RAMESH to display as 'HSEMAR'

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jul 18, 2012 5:11 pm

Do you want a general solution or one for a specific PIC X(6) with that value?

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Jul 18, 2012 5:59 pm

Without using INSPECT as well?
Regards,
Anuj

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Thu Jul 19, 2012 8:46 am

Define the 6 bytes of the "input" individually as pic x.

Define the 6 bytes of the "output" individually as pic x.

Move the fields one at a rime to the desired output positions.

Yes, not a solution that would be uesed in the "real world" but meets the requirement as posted.

If TS does a better job of explaining, we may be able to offer "better" solutions.
Last edited by DikDude on Fri Jul 20, 2012 12:01 am, edited 1 time in total.
Have a good one

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Jul 19, 2012 12:07 pm

Why NOT use intrinsic functions?
Regards
Nic

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Jul 19, 2012 12:30 pm

NicC wrote:Why NOT use intrinsic functions?
Possibly because it's not a practical requirement and done just for fun?! :)
Regards,
Anuj

Hkumar07
Member
Posts: 2
Joined: Tue Jul 17, 2012 2:09 pm

Post by Hkumar07 » Thu Jul 19, 2012 4:32 pm

No special functions. I want in general in reverse format.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Jul 19, 2012 5:06 pm

No special functions. I want in general in reverse format.
that makes no sense whatsoever.
why not use intrinsic functions,
which will perform better than a coded index up and down routine?

by the way, instrinsic functions are a general way to do something.

i should have mentioned something earlier,
i can only assume this is a homework assignment for a class.
(if this is an actual work assignment that eventually go into production
you are wrong. the intrinsic function is the professional way to go)

in the future, it would be better to acknowledge up front,
that this is homework, so that we can better address your requirements.

This is after all a professional forum,
and suggestions are based on experience in the real world.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Jul 19, 2012 11:10 pm

If it IS homework then it is designed to make YOU think. So posting on a forum is totally WRONG.
Regards
Nic

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Jul 20, 2012 12:06 am

No special functions. I want in general in reverse format.
Is this some direction you have been given or is this just something you want to learn . . ?

The "general" way to reverse a set of characters is to use the intrinsic funtion. There is no good reason to have arrays and loops and/or reference modification in the code to do this. Understanding "how" reverse works would be valid, but not wasting time on the more difficult to maintain code that will also use more system resources.
Have a good one

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Jul 20, 2012 4:22 pm

I agree with you, Nic.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others