Code Comments
Programming Forum and web based access to our favorite programming groups.Sorry if this question sounds too basic... I have a numeric stucture to be loaded with known computational values. Example: 01 MY-STRUCT. 03 MY-VALUES OCCURS 200 PIC S9(4) COMP VALUES 10, 20, 30, ... I know the above syntax is not correct, but is there a similar compact way for achieving this? There is a way to do it if the array is defined as PIC X, using REDEFINEs, but I could not find any for a computational one. I do not want to write lots of MOVE statements and I would like to keep it in working storage section. Thanks in advance.
Post Follow-up to this messageOn 23-Mar-2004, mgungora@yahoo.ca (mark) wrote: > 01 MY-STRUCT. > 03 MY-VALUES OCCURS 200 PIC S9(4) COMP VALUES 10, 20, 30, ... > > I know the above syntax is not correct, but is there a similar compact > way for achieving this? There is a way to do it if the array is > defined as PIC X, using REDEFINEs, but I could not find any for a > computational one. I do not want to write lots of MOVE statements and > I would like to keep it in working storage section. Trying not to say too much (It sounds like homework)... You can redefine an 03 level filled with comp s9(4) fields with another 03 l evel filled with comp s9(4) fields.
Post Follow-up to this messagebOTTOM pOSTING mgungora@yahoo.ca (mark) wrote in message news:<508f8f02.0403230653.4ac93090@posting.google.com>... > Sorry if this question sounds too basic... > > I have a numeric stucture to be loaded with known computational > values. > > Example: > > 01 MY-STRUCT. > 03 MY-VALUES OCCURS 200 PIC S9(4) COMP VALUES 10, 20, 30, ... > > I know the above syntax is not correct, but is there a similar compact > way for achieving this? There is a way to do it if the array is > defined as PIC X, using REDEFINEs, but I could not find any for a > computational one. I do not want to write lots of MOVE statements and > I would like to keep it in working storage section. > > Thanks in advance. Whlle you can do it in the way suggested by Howard, if your computational series forms an arithmetic or geometric progression, as suggested by your example, then it might be easier, less long-winded and less error-prone to do the initialisation in a procedure rather than hard-code it in the data division. Robert
Post Follow-up to this messageOn 23-Mar-2004, rjones0@hotmail.com (Robert Jones) wrote: > Whlle you can do it in the way suggested by Howard, if your > computational series forms an arithmetic or geometric progression, as > suggested by your example, then it might be easier, less long-winded > and less error-prone to do the initialisation in a procedure rather > than hard-code it in the data division. And 200 initializations is still cheap.
Post Follow-up to this messageHoward Brazee wrote: > On 23-Mar-2004, rjones0@hotmail.com (Robert Jones) wrote: > > > And 200 initializations is still cheap. Can't be cheaper than PERFORM VARYING I FROM 1 BY 1 UNTIL I > 200 COMPUTE Dataname(I) = f(I) END-PERFORM
Post Follow-up to this message"Howard Brazee" <howard@brazee.net> wrote in message news:<c3pmjj$h82$1@peabody.colorado.ed u>... > On 23-Mar-2004, mgungora@yahoo.ca (mark) wrote: > > > Trying not to say too much (It sounds like homework)... > > You can redefine an 03 level filled with comp s9(4) fields with another 03 level > filled with comp s9(4) fields. It is not homework. According to your suggestion I will have to declare filler fields as many as the size of the array, one line for each. docdwarf has already suggested that, but I was hoping for something else. I thought there might be a way to do it just like doing it for a PIC X array: 01 MY-STRUCT. 03 MY-VALUES OCCURS 200 PIC X. 01 MY-STRUCT-X REDEFINES MY-STRUCT. 03 MY-VALUES-X PIC X(200) VALUE 'ABCDEF................'. This is more compact then doing: 01 MY-STRUCT. 03 MY-VALUES OCCURS 200 PIC X. 01 MY-STRUCT-X REDEFINES MY-STRUCT. 03 FILLER PIC X VALUE 'A'. 03 FILLER PIC X VALUE 'B'. 03 FILLER PIC X VALUE 'C'. 03 FILLER PIC X VALUE 'D'. ... Apparently there is no similar way to do it for computational data... Is that correct? Regards
Post Follow-up to this messageOn 23-Mar-2004, mgungora@yahoo.ca (mark) wrote: > According to your suggestion I will have to declare filler fields as > many as the size of the array, one line for each. docdwarf has already > suggested that, but I was hoping for something else. I thought there > might be a way to do it just like doing it for a PIC X array: > 01 MY-STRUCT. > 03 MY-VALUES OCCURS 200 PIC X. > 01 MY-STRUCT-X REDEFINES MY-STRUCT. > 03 MY-VALUES-X PIC X(200) VALUE 'ABCDEF................'. > > This is more compact then doing: > 01 MY-STRUCT. > 03 MY-VALUES OCCURS 200 PIC X. > 01 MY-STRUCT-X REDEFINES MY-STRUCT. > 03 FILLER PIC X VALUE 'A'. > 03 FILLER PIC X VALUE 'B'. > 03 FILLER PIC X VALUE 'C'. > 03 FILLER PIC X VALUE 'D'. > .... > > Apparently there is no similar way to do it for computational data... > Is that correct? No good way. My question is - why do you prefer compact over clear?
Post Follow-up to this messageOn 23-Mar-2004, "JerryMouse" <nospam@bisusa.com> wrote: > > Can't be cheaper than > > PERFORM VARYING I FROM 1 BY 1 UNTIL I > 200 > COMPUTE Dataname(I) = f(I) > END-PERFORM I would have done the 200 initializations without the "f" above. What did that do?
Post Follow-up to this messageCheck with your compiler vendor and/or current documentation to see if you already support the ISO 2002 VALUE Clause enhancements - or if not, when the vendor plans on supporting it. Doing almost exactly what you have coded below is allowed in the ISO 2002 CO BOL Standard (but not before in Standard COBOL). -- Bill Klein wmklein <at> ix.netcom.com "mark" <mgungora@yahoo.ca> wrote in message news:508f8f02.0403230653.4ac93090@posting.google.com... > Sorry if this question sounds too basic... > > I have a numeric stucture to be loaded with known computational > values. > > Example: > > 01 MY-STRUCT. > 03 MY-VALUES OCCURS 200 PIC S9(4) COMP VALUES 10, 20, 30, ... > > I know the above syntax is not correct, but is there a similar compact > way for achieving this? There is a way to do it if the array is > defined as PIC X, using REDEFINEs, but I could not find any for a > computational one. I do not want to write lots of MOVE statements and > I would like to keep it in working storage section. > > Thanks in advance.
Post Follow-up to this messageHoward Brazee wrote: > On 23-Mar-2004, "JerryMouse" <nospam@bisusa.com> wrote: > > > I would have done the 200 initializations without the "f" above. > What did that do? Oh, sorry. The "f(x)" notation is mathematical standing for "some function of "x". In the original case, the actual code would have been: COMPUTE MYVALUES(I) = I * 10
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.