Code Comments
Programming Forum and web based access to our favorite programming groups.Hi: I am trying to let a customer input the number of decimal points to round to. How can I code this in working storage so I can calc a subscript based on input from the customer. I would like to avoid creating 7 different paragraphs for each option if possible. I have created a sample program to test this below, and I just chose to use a sub of 4. Ref-field turns up with no decimals. Anyone have any suggestions on how I can pull this off. MicroFocus Netexpress 3.1. IDENTIFICATION DIVISION. PROGRAM-ID. testperf. ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 test-fields. 05 filler pic s9(12)v99. 05 T2 pic s9(11)v999. 05 T3 pic s9(10)v9999. 05 T4 pic s9(09)v99999. 05 T5 pic s9(08)v999999. 05 T6 pic s9(07)v9999999. 05 T7 pic s9(06)v99999999. 01 tf redefines test-fields. 05 ref-field pic 9(14) occurs 7 times. * * 01 test-out pic s9(6)v99. *-------------------------------------- 01 Field1 pic 9(5)v9(10) value zero. 01 Field2 pic 9(5)v9(5) value 123.45600. 01 field3 pic 9(5)v9(3) value 435.553. PROCEDURE DIVISION. testperform-begin. compute ref-field (4) rounded = field2 * Field3. Move zeros to test-out. * compute test-out = test-out + tf(4). P1101-END. STOP RUN.
Post Follow-up to this messageThe easy way involves the use of a scale factor instead of 7 work fields. > In article <Xw3nc.9299$2f6.376381@twister.tampabay.rr.com>, > Jerry Huff <jhuff@terrasoftsystems.com> wrote: >
Post Follow-up to this messageJerry Huff wrote: > Hi: > I am trying to let a customer input the number of decimal points to > round to. > How can I code this in working storage so I can calc a subscript based > on input from the customer. I would like to avoid creating 7 different > paragraphs for each option if possible. I have created a sample > program to test this below, and I just chose to use a sub of 4. > Ref-field turns up with no decimals. Anyone have any suggestions on > how I can pull this off. MicroFocus Netexpress 3.1. > > IDENTIFICATION DIVISION. > PROGRAM-ID. testperf. > ENVIRONMENT DIVISION. > CONFIGURATION SECTION. > INPUT-OUTPUT SECTION. > FILE-CONTROL. > DATA DIVISION. > FILE SECTION. > > WORKING-STORAGE SECTION. > 01 test-fields. > 05 filler pic s9(12)v99. > 05 T2 pic s9(11)v999. > 05 T3 pic s9(10)v9999. > 05 T4 pic s9(09)v99999. > 05 T5 pic s9(08)v999999. > 05 T6 pic s9(07)v9999999. > 05 T7 pic s9(06)v99999999. > 01 tf redefines test-fields. > 05 ref-field pic 9(14) occurs 7 times. > * > * > 01 test-out pic s9(6)v99. > *-------------------------------------- > 01 Field1 pic 9(5)v9(10) value zero. > 01 Field2 pic 9(5)v9(5) value 123.45600. > 01 field3 pic 9(5)v9(3) value 435.553. > > PROCEDURE DIVISION. > testperform-begin. > compute ref-field (4) rounded = > field2 * Field3. > > Move zeros to test-out. > * compute test-out = test-out + tf(4). > P1101-END. > STOP RUN. > First, which one of the following are you using :- 1) Screen Section 2) Dialog Editor and GUI classes 3) Dialog System Now would you care to expand on your statement, " I am trying to let a customer input the number of decimal points to round to.". Is this :- - on the fly, - do you have a Condition (Level 88) set as to what is currently acceptable as the input length, or, - are there specific lengths to specific input fields, (per Screen/Dialog) or, - does the user set a Default length before application start-up or, - etc......... ? Knowing what the 'design intent' is will make it easier to suggest an answer rather than follow up on your code above, which doesn't indicate how the input is triggered. Jimmy, Calgary AB
Post Follow-up to this messageOn 8-May-2004, Jerry Huff <jhuff@terrasoftsystems.com> wrote: > Hi: > I am trying to let a customer input the number of decimal points to > round to. I would consider rounding by hand. COMPUTE MY-RESULT = MY-RESULT + 5 / 10 ** DIGITS Then move the string using reference modification to another alpha string.
Post Follow-up to this message"Howard Brazee" <howard@brazee.net> wrote: >On 8-May-2004, Jerry Huff <jhuff@terrasoftsystems.com> wrote: > > >I would consider rounding by hand. > >COMPUTE MY-RESULT = MY-RESULT + 5 / 10 ** DIGITS > >Then move the string using reference modification to another alpha string. Close. It should be .5 rather than 5, and doesn't work for negative numbers. 05 edited-number pic z(9).9(6). 05 edited-number-variable-length redefines edited-number. 10 pic x(10). 10 occurs 1 to 6 depending on digits pic x. compute edited-number = my-result + (function sign (my-result) * .5 / (10 ** digits)) move edited-number-variable-length to ...
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.