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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

+ or ++ 2

Status
Not open for further replies.

randy700

Programmer
Sep 25, 2003
2,384
0
0
US
I'm working on a project that requires me to extract data from various files and build text files. The users want a + or - sign in front of all signed numeric fields.

My question is...
What is the difference between these 2 picture clauses?
PIC +9(06).99
PIC ++9(06).99


They seem to product the same results.


Randy
 
Yes really not much, but there IS a difference. + is a substitution-oriented character in a PIC clause while 9 is not. Which means this: Both definitions will produce a leading +, but will also produce a number of zeros before the dot if you move a value less than 7 before the first and 8 before the second.

Best to use PIC ++++++9.99 (depending on whether you care about having a leading zero before the dot or not, so the floating sign will occur in all your numbers.


It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
So, if I WANT the leading zeroes, PIC +9(06).99 would be the way to go?


Randy
 
Yes.
With ++9(06).99, you'll probably get an extra space.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
One note, though, neither of us brought up before. You generally want to define one more + than what the number is intended. If you do 7 +'s and put a 7 digit number in the value, you won't get the sign at all.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Actually, you will get the sign, but won't get the high-order digit.
 
But all this is in the COBOL Language Reference manual under a title like PICTURE EDIT CHARACTERS or similar with which you should be familiar BEFORE you start coding.


Nic
 
But all this is in the COBOL Language Reference manual under a title like PICTURE EDIT CHARACTERS or similar with which you should be familiar BEFORE you start coding
So, you're saying I shouldn't have asked this question?
Sorry to have bothered you, but it doesn't seem the other members had any objection to helping me out.


Randy
 
Randy -

I won't defend Nic's post, but I will point out that those of us who are experienced COBOL coders are often asked questions which could be easily answered if one were simply to read/study the manual. I, for one, am amazed at the number of COBOL coders who have never opened the manual for the COBOL compiler that they use; relying, instead, on what they learned in a textbook or classroom, or picked up on their own over the years. I am happy when one of my employees has a coding question IF they show that they've taken the initiative to "look it up" or experiment with it BEFORE they come knocking on my door.

COBOL is a very powerful language and each manufacturer of a COBOL compiler has implemented vendor-specific options and enhancements. I think a professional should be intimately familiar with his or her tools and, for coders, that includes a reasonably thorough study of the language reference manual(s).

Finally, this forum is a pretty friendly place. I've been elsewhere when a question like yours would elicit a dozend single-word responses of "RTFM!". By comparison, Nic's response was not so bad.

Regards,

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top