Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

loading a numeric array
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.

Report this thread to moderator Post Follow-up to this message
Old Post
mark
03-27-04 04:00 AM


Re: loading a numeric array
On 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-27-04 04:00 AM


Re: loading a numeric array
bOTTOM 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

Report this thread to moderator Post Follow-up to this message
Old Post
Robert Jones
03-27-04 04:00 AM


Re: loading a numeric array
On 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-27-04 04:00 AM


Re: loading a numeric array
Howard 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




Report this thread to moderator Post Follow-up to this message
Old Post
JerryMouse
03-27-04 04:00 AM


Re: loading a numeric array
"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

Report this thread to moderator Post Follow-up to this message
Old Post
mark
03-27-04 04:00 AM


Re: loading a numeric array
On 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?

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-27-04 04:00 AM


Re: loading a numeric array
On 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?

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-27-04 04:00 AM


Re: loading a numeric array
Check 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.



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
03-27-04 04:00 AM


Re: loading a numeric array
Howard 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



Report this thread to moderator Post Follow-up to this message
Old Post
JerryMouse
03-27-04 04:00 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:16 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.