IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Referential read of an array element


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 26, 2012 4:18 pm
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: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 26, 2012 5:32 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 26, 2012 6:25 pm
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: 6966
Location: porcelain throne

PostPosted: Thu Apr 26, 2012 6:34 pm
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

Senior Member


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

PostPosted: Thu Apr 26, 2012 8:05 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts ICETOOL to Read records SMF CEF it is... DFSORT/ICETOOL 4
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
Search our Forums:

Back to Top