View previous topic :: View next topic
|
Author |
Message |
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
My field is defined as
01 FIELD PIC -,---,--9.99.
01 FIELD-R REDIFINES FIELD PIC X(12).
Some numeric value is moved in FIELD, e.g. -101.75
when displayed it prints as -101.75
What I want to print is (101.75)
I can eazily put ')' as it's position is fix. Problem is with '(' as its position depends upon the size of the number.
We are using '-' for leading zero suppressing. Can i use INSPECT to replace this '-' with '('.
I have tried
INSPECT FIELD RELACING '-' BY '('
INSPECT FIELD-R RELACING '-' BY '(' ......... Nothing is working
Any work around ?? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
1) The COBOL code you posted won't compile -- it is REPLACING not RELACING. This is why people are told, repeatedly, to cut and paste the code instead of typing it again -- typos can drastically change the meaning of the posted code.
2) Have you tried INSPECT FIELD-R REPLACING FIRST '-' BY '('. ? |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
INSPECT FIELD-R (or FIELD) REPLACING ALL "-" BY "(".
works for me |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
donevin wrote: |
INSPECT FIELD-R (or FIELD) REPLACING ALL "-" BY "(".
works for me |
I have tried LEADING '-' ..not ALL
will check
Thanks |
|
Back to top |
|
|
hsk
New User
Joined: 28 Nov 2006 Posts: 69 Location: India
|
|
|
|
That works ......
Probably the "LEADING" in the command was causing problems
Thanks you guys !! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Since the first character in your field, once substituted, is a space and not a '(' the LEADING won't work. FIRST will work, ALL will work -- but LEADING means leading: if there's another character in the first position instead of the character you're looking for, the INSPECT is done. |
|
Back to top |
|
|
donevin
New User
Joined: 07 Jun 2005 Posts: 70 Location: South Africa
|
|
|
|
First is then the most accurate in terms of syntax and intention in my opinion. |
|
Back to top |
|
|
|