reverse the order of a string using cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: reverse the order of a string using cobol

Postby tivrfoa » Mon Jan 27, 2014 8:28 pm

dick scherrer wrote:I would reverse the "string", note the position of the first non-blank, and then move the "right-side" of the string to the output field (using reference modification as you know where to start and can calculate the length of the data to be moved..

Hi d.scherrer,

It would help a lot if you could post code. :D
I don't know how to implement what you're saying. "reference modification"??
tivrfoa
 
Posts: 83
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 58 times
Been thanked: 0 time

Re: Re: reverse the order of a string using cobol

 

Re: reverse the order of a string using cobol

Postby dick scherrer » Mon Jan 27, 2014 8:41 pm

Hello,

I don't know how to implement what you're saying. "reference modification"??
   MOVE TMP-STR(J:I - J) TO TMP-WORD
You are already using reference modification in your code . . . :?

Where are you "stuck"?

We (i) will help you develop the code, but not do the work for you.

Think about what you want to accomplish using what you have.
1. calculate the length of the data to be moved (using the reversed string).
2. move the reversed data (specifying starst and length) to the output field (after moving spaces to the output field).

Let us know if there are questions or problems.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: reverse the order of a string using cobol

Postby tivrfoa » Mon Jan 27, 2014 9:01 pm

dick scherrer wrote:
   MOVE TMP-STR(J:I - J) TO TMP-WORD
You are already using reference modification in your code . . . :?

So this is reference modification ...
dick scherrer wrote:We (i) will help you develop the code, but not do the work for you.

I'm not the one that created the topic. Code clarifies a lot. You said that wouldn't use STRING and UNSTRING each time thru the loop, so you could have posted some alternative code.
tivrfoa
 
Posts: 83
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 58 times
Been thanked: 0 time

Re: reverse the order of a string using cobol

Postby NicC » Mon Jan 27, 2014 10:26 pm

so you could have posted some alternative code

Why? Nobody is paying people for their work here. Everyone is supposed to think about solutions - not be spoon-fed like babies.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: reverse the order of a string using cobol

Postby dick scherrer » Mon Jan 27, 2014 10:53 pm

Hello,

Code clarifies a lot. You said that wouldn't use STRING and UNSTRING each time thru the loop, so you could have posted some alternative code.
Grabbing code and shoving it into your porgram is not much clarification. Learning how to implement the code will make it More clear.

I believe i also said i would use the MOVE with reference modification rather than a STRING/UNSTRING.

I'm not the one that created the topic.

You might not have started the topic, but when someone mentions posting code, my usual response is that we will help, but i usually do not post code.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post