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

Advice on Arrays


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
SlippingJimmy

New User


Joined: 21 Sep 2022
Posts: 10
Location: USA

PostPosted: Fri Oct 21, 2022 7:20 pm
Reply with quote

A little background, I come from Java and JavaScript background, and PL/I is really new to me. Bear with me on this learning journey.

This is the code I am working with:

Code:

dcl NAME             varying char(8);
dcl COUNT            fixed bin(15) init(0);
dcl TOTALS(5,5)    char(8);


In the array I need to add the names in *,1 then the count in *,2.
As I understand it, in PL/I convention, the array cannot be mixed data types, in the languages I know it is easier to convert the Integer to a string and push it in the area of the array I need it in and convert it back to an Integer when I need to be an int. Well, PL/I doesn’t have that option because I scoured the documentation and read just about every built-in function known to man/woman here.

What’s the best way to handle this?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Oct 21, 2022 8:13 pm
Reply with quote

read the pl/i reference manual whare it talks about

Aggregate combinations and mapping
..Combinations of arrays, structures, and unions
..Cross sections of arrays of structures or unions
..Structure and union operations
..Structure and union mapping

and the pages that follow
Back to top
View user's profile Send private message
SlippingJimmy

New User


Joined: 21 Sep 2022
Posts: 10
Location: USA

PostPosted: Fri Oct 21, 2022 9:04 pm
Reply with quote

enrico-sorichetti wrote:
read the pl/i reference manual whare it talks about

Aggregate combinations and mapping
..Combinations of arrays, structures, and unions
..Cross sections of arrays of structures or unions
..Structure and union operations
..Structure and union mapping

and the pages that follow


I can’t use structures. I should have clarified that in the original post, my fault.

I can use
Code:
BINARY
to convert it into an Integer but I can't figure out how to convert it to a string.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Fri Oct 21, 2022 10:13 pm
Reply with quote

SlippingJimmy wrote:

I can’t use structures. I should have clarified that in the original post, my fault.

Please, clarify:
1) you don't know how to use it?
2) your management doesn't know how to use it?
3) your compiler doesn't support it?
4) what else? - I cannot imagine...

If you "cannot use PL/I structures", then switch to another appropriate tool...

Or, you can define two separate arrays, with appropriate attributes!
Back to top
View user's profile Send private message
SlippingJimmy

New User


Joined: 21 Sep 2022
Posts: 10
Location: USA

PostPosted: Fri Oct 21, 2022 10:40 pm
Reply with quote

sergeyken wrote:

Please, clarify:
2) your management doesn't know how to use it?


My management stated the code I’ll be maintaining doesn’t use structs, so it isn’t important for me to learn them currently.

sergeyken wrote:

you can define two separate arrays, with appropriate attributes!

Is there a way to map the names and counts to one another? The output should be as such without the brackets of course.
Code:

[
[name], [count],
[name], [count]

]
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Fri Oct 21, 2022 11:09 pm
Reply with quote

SlippingJimmy wrote:

Is there a way to map the names and counts to one another? The output should be as such without the brackets of course.
Code:

[
[name], [count],
[name], [count]

]


Something like this.
Code:
DO I = 1 TO 5;
   PUT EDIT( NAMES(I), TOTALS(I) )
           ( A(10),    F(10)     );
END I;


It's a huge problem, the total degradation of technical management... icon_evil.gif icon_rolleyes.gif
Back to top
View user's profile Send private message
SlippingJimmy

New User


Joined: 21 Sep 2022
Posts: 10
Location: USA

PostPosted: Sat Oct 22, 2022 1:54 am
Reply with quote

sergeyken wrote:

Something like this.
Code:
DO I = 1 TO 5;
   PUT EDIT( NAMES(I), TOTALS(I) )
           ( A(10),    F(10)     );
END I;



Awesome thank you!
I was dreading using 2D arrays.

sergeyken wrote:

It's a huge problem, the total degradation of technical management... icon_evil.gif icon_rolleyes.gif


My manager is really good, he's trying to get me up to speed probably a little too fast but I can understand the reason. Are there really a shortage of PL/I developers?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Sat Oct 22, 2022 6:55 pm
Reply with quote

SlippingJimmy wrote:

My manager is really good, he's trying to get me up to speed probably a little too fast but I can understand the reason. Are there really a shortage of PL/I developers?

All modern experts schooled on Javas and Pythons do belong to the lost generation, forever… icon_cry.gif
Back to top
View user's profile Send private message
SlippingJimmy

New User


Joined: 21 Sep 2022
Posts: 10
Location: USA

PostPosted: Wed Oct 26, 2022 5:50 pm
Reply with quote

sergeyken wrote:

All modern experts schooled on Javas and Pythons do belong to the lost generation, forever… icon_cry.gif


Not really... You can see that here but that doesn't mean COBOL and PL/I are going anywhere
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Wed Oct 26, 2022 6:09 pm
Reply with quote

SlippingJimmy wrote:
sergeyken wrote:

All modern experts schooled on Javas and Pythons do belong to the lost generation, forever… icon_cry.gif


Not really... You can see that here but that doesn't mean COBOL and PL/I are going anywhere

Whatever those tables show, but starting career from Java and Python is definitely the way to cerebral atrophy.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 26, 2022 8:09 pm
Reply with quote

Quote:
but starting career from Java and Python is definitely the way to cerebral atrophy.


Professor Edsger Dijkstra thought the same about cobol
www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

icon_lol.gif icon_lol.gif icon_lol.gif
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Advice re:rejoining mainframe workfor... All Other Mainframe Topics 6
No new posts MIN-, MAX-function with arrays COBOL Programming 3
No new posts Need advice on sort card JCL & VSAM 16
No new posts Index and subscript in Arrays COBOL Programming 9
No new posts Advice on an optimal unload solution DB2 8
Search our Forums:

Back to Top