Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Referential read of an array element

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
nightbuzzz

New User


Joined: 04 May 2007
Posts: 21
Location: kuala lumpur

PostPosted: Thu Apr 26, 2012 4:05 pm    Post subject: Referential read of an array element
Reply with quote

Hi,

I want to read an element's last 3 characters which is present in an array variable.

Please let me know how can i do it.

eg:-

an array element ws-array(1) contains 'ABCDEFGH'. I want to move just FGH to another variable, then how can i do it.

Thanks in advance
Mayank
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Apr 26, 2012 4:18 pm    Post subject: Reply to: Referential read of an array element
Reply with quote

Code:
    10  nicely-named-item-in-a-table pic x(8).
    10  filler redefines nicely-named-item-in-a-table.
        15  filler pic x(5).
        15  nicely-name-end-of-item-in-a-table PIC XXX.

MOVE nicely-name-end-of-item-in-a-table ( subscripted ) TO wherever-you-need-it
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8054
Location: East Dubuque, Illinois, USA

PostPosted: Thu Apr 26, 2012 5:32 pm    Post subject:
Reply with quote

Mayank, your post left MANY unanswered questions:
1. Are the variables in the table always 8 bytes long?
2. Are you always wanting bytes 6 through 8 moved (assuming the table element variables are always 8 bytes long)?
3. If either of these questions is negative, you need to more fully explain what you want.

You could use reference modification as well:
Code:
MOVE TABLE-ELEMENT (tbl-ndx) (6 : 3) TO ...
would move bytes 6 through 8 of the TABLE-ELEMENT variable pointed to by tbl-ndx, for example.
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Thu Apr 26, 2012 5:46 pm    Post subject: Reply to: Referential read of an array element
Reply with quote

Code:
* Assuming Ws-array is Pic X(08)
 Move Ws-array(1)(6:) to wherever-you-need-it
* else
 Move Ws-array(1)(6:3) to wherever-you-need-it
 
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Apr 26, 2012 6:25 pm    Post subject: Reply to: Referential read of an array element
Reply with quote

Looks like I'm outnumbered :-)

I like a program to tell it's own story to the next reader. Not leave them having to wonder "what was at 6 for a length of 3? Anyone any idea?" They'll be posting the question here :-)

If you can do it without reference-modification, do so, with nice names. I know there is all that extra thinking, and typing, but I've never found that thinking about a program is a problem, and the typing doesn't really amount to much.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Thu Apr 26, 2012 6:34 pm    Post subject:
Reply with quote

Bill,
I agree with you, REFERENCE MODIFICATION is not something to be used, freely.

Often it is the easiest solution
when a design is changed (suddenly a need for a part of a field).

but it is very poor if it is part of the original design.

and that is where you find most reference modification,
in the original design.

that is the trouble with programmers who want to HLASM in COBOL.
they are of the same mentality as the jerks who insist on referencing
the structures within an FD instead of using the WORK-AREA Option with i/o.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Thu Apr 26, 2012 8:05 pm    Post subject:
Reply with quote

I concur on good names.

Programmers produce programs - readable (elegant?) documents.

It's the programs that produce files.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Read of TDQ fails in LENGERR Tracy Hansen CICS 10 Wed Apr 05, 2017 12:10 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts CICS VSAM RLS READ akodakka CICS 3 Tue Oct 04, 2016 3:09 pm
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us