INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

write apostrophe in cobol

write apostrophe in cobol

(OP)
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.

RE: write apostrophe in cobol

Try
 INSPECT MYVARIABLE  REPLACING FIRST '''' BY space.

RE: write apostrophe in cobol

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
http://tubularity.com

RE: write apostrophe in cobol

(OP)
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.

RE: write apostrophe in cobol

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

RE: write apostrophe in cobol

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

RE: write apostrophe in cobol

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

RE: write apostrophe in cobol

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
http://tubularity.com

RE: write apostrophe in cobol

(OP)
GOOOOOOOOOOOOOD!!

Thanks you guys,

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


Thanks a lot...

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close