×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

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!
  • Students Click Here

*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.

Students Click Here

Jobs

+ or ++
2

+ or ++

+ or ++

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

RE: + or ++

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.

RE: + or ++

(OP)
So, if I WANT the leading zeroes, PIC +9(06).99 would be the way to go?
 

Randy

RE: + or ++

(OP)

Thanks to both of you.

Randy

RE: + or ++

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.

RE: + or ++

Actually, you will get the sign, but won't get the high-order digit.

RE: + or ++

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

RE: + or ++

(OP)

Quote:

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

RE: + or ++

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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