View previous topic :: View next topic
|
Author |
Message |
ajit007_cool
New User
Joined: 08 Sep 2008 Posts: 14 Location: basel
|
|
|
|
In my cobol values for variables is declared within single quotes as below
01 W-VARIABLE PICX(4) VALUE 'AJIT'.
Now if i wish to search a quote within a sting i have no clue how to it . because it wont allow any of the following.
INSPECT WS_VARIABLE REPLACING ALL ' ' ' BY ' '.
OR
INSPECT WS_VARIABLE REPLACING ALL" ' " BY ' '.
OR
INSPECT WS_VARIABLE REPLACING ALL QUOTE BY SPACE. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
you need to use '''' (four times quote) to refer one quote. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the QUOTE figurative literal should works.
I defined a field with VALUE ALL QUOTES.
my inspect statement is as follows:
INSPECT WORKING-FIELD
REPLACING ALL QUOTES BY SPACES
and
INSPECT WORKING-FIELD
REPLACING ALL QUOTE BY SPACE
in COBOL II it both work
what compiler error are you getting? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
W-VARIABLE PICX(4) VALUE 'AJIT'.
Now if i wish to search a quote within a sting i have no clue how to it . because it wont allow any of the following.
INSPECT WS_VARIABLE REPLACING
|
probably complaining about WS_VARIABLE which 1) is not a legal reference name and 2) the working storage variable you provided is W-VARIABLE. ws and w. Attention to detail!!!! |
|
Back to top |
|
|
ajit007_cool
New User
Joined: 08 Sep 2008 Posts: 14 Location: basel
|
|
|
|
my input string is
00006044;TEST'9
output must be
00006044;TEST 9
samabajhi i tried ur suggestion , but it didnt worked.
hey dick i tried this earlier but i didnt recieved any compiler error but my output remained same
INSPECT WORKING-FIELD
REPLACING ALL QUOTE BY SPACE |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what is your working storage definition of working-field? |
|
Back to top |
|
|
ajit007_cool
New User
Joined: 08 Sep 2008 Posts: 14 Location: basel
|
|
|
|
0008 02 LDA-SUBJ PIC X(107).
and it has data as below
00006044;TEST'9 ;BSL;TEST'6 ;TEAT'5
and i want it to be like
00006044;TEST 9 ;BSL;TEST 6 ;TEAT 5 |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Ajit,
Am wondering why it is not working..
below is code i tried and working fine at my end...
Code: |
*working storage def.
01 MYVAR1 PIC X(30) VALUE '00006044;TEST''9'.
.
.
.
*procedure div
.
.
DISPLAY 'INPUT: ' MYVAR1.
INSPECT MYVAR1
REPLACING ALL '''' BY SPACE.
DISPLAY 'OUTPUT: 'MYVAR1.
.
.
.
*output is
INPUT: 00006044;TEST'9
OUTPUT: 00006044;TEST 9
|
Is it the same you want? |
|
Back to top |
|
|
ajit007_cool
New User
Joined: 08 Sep 2008 Posts: 14 Location: basel
|
|
|
|
earlier i was using
INSPECT MYVAR1
REPLACING ALL '''' BY ' '.
this was not working
now i used urone it worked thanks a lot
thank u very much |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
U R WEL-C ME.. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Ajit,
The main thing to remember, is that to represent a quote within quotes, you must use 2 quotes. Soooo:
If the string is ABC'DEF you represent it as 'ABC''DEF'.
If the string is ' you represent it as ''''.
The rule is the same in both cases, but they look different. |
|
Back to top |
|
|
ajit007_cool
New User
Joined: 08 Sep 2008 Posts: 14 Location: basel
|
|
|
|
thanks jack |
|
Back to top |
|
|
deepak4wd
New User
Joined: 24 Apr 2006 Posts: 4
|
|
|
|
Hi all,
can some one tell the logic to convert double qouted string to single qouted string using the inspect claues according to above discussion.
thanks. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
can some one tell the logic to convert double qouted string to single qouted string using the inspect claues according to above discussion.
|
What have you tried seeing above discussion?? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If you use the hex-notation for a Quote (X'7D') and an INSPECT CONVERTING, this will be the most efficient process.
INSPECT REPLACING causes a the compiler to BALR to a COBOL Run Time routine, whereas, INSPECT CONVERTING (with literals) causes the compiler to build an in-line TR instruction with a Translate-Table.
Regards,
Bill |
|
Back to top |
|
|
deepak4wd
New User
Joined: 24 Apr 2006 Posts: 4
|
|
|
|
Thank you bill, I'll try the same.
thanks a lot for the quick reply. |
|
Back to top |
|
|
|