Posted: Tue Dec 06, 2016 8:41 pm Post subject: Reply to: Performing arithmetic on input field

I opened a DFSORT Application Programming Guide (I used 2.1) PDF and used the PDF-reader to search for 'mul,' (quotes not needed for the search) and readily located several examples of the use of multiple arithmetic operands.

Posted: Wed Dec 07, 2016 3:27 pm Post subject: Reply to: Performing arithmetic on input field

Thanks Bill. I was expecting this reply.
I have 2012 version of DFSORT Application Programming Guide, I can't see any example for multiplication there.

Posted: Wed Dec 07, 2016 8:38 pm Post subject: Reply to: Performing arithmetic on input field

If you don't specify a length (with LENGTH or an explicit EDIT mask) you get a default length. If you don't provide an explicit EDIT, you get a default mask.

"I" in an EDIT means "a blank if there is no significant digit encountered yet", so leading zeros you ask to be blank.

You need a + (or -) because that is how DFSORT will tell if you are specifying a numeric literal, or the (incomplete) start of a field definition.

I'm pretty sure the examples for 2.1 are the same as for 2.2, for instance, p136 in both documents:

Quote:

arexp,edit or (arexp),edit
specifies that the edited result of an arithmetic expression is to appear in the reformatted input record. The arithmetic expression can consist of input fields, decimal constants, operators and parentheses. An arithmetic expression produces a signed, 31-digit zoned decimal (ZD) result to be edited as specified.
See arexp,edit under OUTFIL OUTREC for details.

Joined: 17 Oct 2006 Posts: 2355 Location: @my desk

Posted: Wed Dec 07, 2016 8:44 pm Post subject:

zh_lad,

I would suggest keeping all the intermediate multiplication results in 2 bytes, so you don't have to figure out later which result has 2 digits and which one has 1 digit. Because you need to sum all of them later. It might add more work and confusion if you get rid of the blanks, and then try to figure out where each intermediate result starts.

So you can use TT...edits and read them as ZD in further computations or keep the IT...edits and read them as UFF, whichever works for you.

Posted: Wed Dec 07, 2016 9:26 pm Post subject: Reply to: Performing arithmetic on input field

And multiple arithmetic operations can be carried out without having to define anything for intermediate results. The next operation is on "the current result" for as long as necessary without having to be concerned about it.

Posted: Wed Dec 07, 2016 10:18 pm Post subject: Re: Reply to: Performing arithmetic on input field

Thanks Bill.

1. I learnt it later when I read about Mask.
2. I am aware of use of 'I' in EDIT
3. I didn't know, I was using arithmetic first the first in SORT - Thanks
4. Yes PDF has examples but always problem is discussed on different page. Ideally it should have link to go directly to the problem description by one click. It difficult to absorb example (sample) if problem is discussed on a different page.

Thanks for your comments. They helped to use PDF better.

Bill Woodger wrote:

If you don't specify a length (with LENGTH or an explicit EDIT mask) you get a default length. If you don't provide an explicit EDIT, you get a default mask.

"I" in an EDIT means "a blank if there is no significant digit encountered yet", so leading zeros you ask to be blank.

You need a + (or -) because that is how DFSORT will tell if you are specifying a numeric literal, or the (incomplete) start of a field definition.

I'm pretty sure the examples for 2.1 are the same as for 2.2, for instance, p136 in both documents:

Quote:

arexp,edit or (arexp),edit
specifies that the edited result of an arithmetic expression is to appear in the reformatted input record. The arithmetic expression can consist of input fields, decimal constants, operators and parentheses. An arithmetic expression produces a signed, 31-digit zoned decimal (ZD) result to be edited as specified.
See arexp,edit under OUTFIL OUTREC for details.

Joined: 17 Oct 2006 Posts: 2355 Location: @my desk

Posted: Wed Dec 07, 2016 10:25 pm Post subject:

Quote:

Thanks Rohit, it worked

But I am afraid that is not what you were trying to achieve. Like Bill mentioned above, you can have multiple computations, just use braces to have meaningful results and then edit the final result as needed.

You don't need to worry about the format of intermediate results because, as suggested you can do multiple computations one after the other, like this and edit only the final result.

Posted: Thu Dec 08, 2016 12:29 am Post subject: Reply to: Performing arithmetic on input field

IFTHEN=(WHEN=INIT for an OVERLAY to give you the several multiply-by-two results (they are not "intermediate results" in the sense normally used), then another WHEN=INIT with the BUILD to ADD all the digits that you need (odd-number from original location, even-numbered from the location OVERLAYed to) and then multiply that by +9.

Posted: Thu Dec 08, 2016 4:24 am Post subject: Reply to: Performing arithmetic on input field

No-one locked anything, and that last comment wasn't mine :-)

Posts can only be edited by non-moderators for 10 minutes after they have been entered. If you can post (or PM) me a correction I can apply it and tidy up a bit.

Posted: Thu Dec 08, 2016 7:46 pm Post subject: Re: Reply to: Performing arithmetic on input field

Hi Bill,

How will I deal with space when result of multiplication is only 1 digit.

Code:

1,1,UFF,MUL,+2,EDIT(IT)

How will I ignore space to pick up digits to sum in OUTREC (second IFTHEN).

Rohit was using FIND and REPLACE

Code:

OUTREC FINDREP=(INOUT=(C' ',C''))

Thanks.

Bill Woodger wrote:

IFTHEN=(WHEN=INIT for an OVERLAY to give you the several multiply-by-two results (they are not "intermediate results" in the sense normally used), then another WHEN=INIT with the BUILD to ADD all the digits that you need (odd-number from original location, even-numbered from the location OVERLAYed to) and then multiply that by +9.