Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write apostrophe in cobol

Status
Not open for further replies.

Sasquatch69

Programmer
Sep 20, 2002
19
CA
Hi, i need to replace all apostrophe(') in a string.

i use this:
INSPECT MYVARIABLE REPLACING FIRST 'apostrophe' BY space.

How can i write apostrophe in that case??? (''',not work)

thanks a lot.
 
Try
INSPECT MYVARIABLE REPLACING FIRST '''' BY space.
 
Not entirely sure what you are asking however some general comments.

Depending on the compiler and its options you can have a single quote within double quotes or a double quote within singles quotes. eg.

01 STRING-1 PIC X(7) VALUE "---'---".
01 STRING-2 PIC X(7) VALUE '---"---'.

If you need mixed double and single quotes within either single or double quotes you can substitute another character for the single and double quotes and then convert them when writing out the line. EG.

Substitute x'F8' for double quotes and x'FB' for single quotes and then when writing out the line do this

MOVE STRING-3 TO PRINT-LINE.
INSPECT PRINT-LINE REPLACING ALL x'FB' BY x'27'.
INSPECT PRINT-LINE REPLACING ALL x'F8' BY x'22'.

Clive
 
thank you CliveC and Dimandja, but it doesn't work.

I just want to replace all apostrophe in a string with a space. Exemple of my string, a town call VAL D'OR.

I don't know how i can do my inspect because i have to put my apostrophe between two apostrophe ( ''').

Clive, i do what you said, but my compiler don't take it in COBOL. If compile it in COBOL2 it seem to work(no compiling error) but my apostrophe is always in my String.

Sorry for my bad english... thank you.
 
Did you try this?
INSPECT MYVARIABLE REPLACING FIRST '''' BY space.

That's 2 apostrophies within 2 enclosing apostrophies, for a total of 4.

Let me know what happens.

Dimandja
 
I may be off base posting in the Fujitsu forum as I am not familiar with that compiler :)

You may be able to use the literal QUOTE to represent an apostrophe. That certainly works on mainframe compilers and on other compilers where one can choose to use either single or double quotes as the QUOTE character.

The other posters' approaches are generally viable too, depending on compiler, options etc. (I assume Dimandja meant "'" i.e. quote apostrophe quote?)

3gm
 
Hi 3gm,

My compiler (Tandem COBOL85 supports your constructs, including "'").

My compiler also allows """" when a quote is quoted. I assumed that compilers that use single quotes (as seemes to be the case here)would support a similar approach ''''.

Dimandja
 
If you want ALL why are you saying FIRST?

Can you refer to the hex values in Fujitsu? If so how about:

INSPECT MYVARIABLE REPLACING ALL x'27' BY SPACE.

Hope that helps! Clive
 
GOOOOOOOOOOOOOD!!

Thanks you guys,

It working, i try The Dimandja solution and it works.


Thanks a lot...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top