Page 1 of 1

Find a position in variable and update.

Posted: Fri Jan 17, 2014 5:06 pm
by Prem_mainframe
Hi,

In a COBOL

Variable1 PIC X(36) value '0123456789abcdefghijklmnopqrstuvwxyz'.

I want to firstly search the character, for example 'c', later want to update the character 'c' to '$'. In the output i need to display, the character position, chrrent value and the replaced value - how should I proceed for this.

Thank you

Re: Find a position in variable and update.

Posted: Fri Jan 17, 2014 5:25 pm
by Robert Sample
Use INSPECT. It allows TALLYING as well as REPLACING.

Re: Find a position in variable and update.

Posted: Fri Jan 17, 2014 5:52 pm
by zprogrammer
Just trying to understand :

Do you want to replace all 'c' in the given string?

Re: Find a position in variable and update.

Posted: Mon Aug 11, 2014 2:55 pm
by Prem_mainframe
Yes, I wanted to replace all the 'c's.

Re: Find a position in variable and update.

Posted: Mon Aug 11, 2014 3:40 pm
by William Collins
Use a loop with PERFORM.

Re: Find a position in variable and update.

Posted: Wed Aug 20, 2014 2:41 pm
by Prem_mainframe
Thanks William.