Hello Forum,
I was try to find if any builtin function to get current size of all elements in total of a dynamic array allocated using controlled storage class. I am searching for builtin function to reduce LOC!
Builtin Function to get total size of a dynamic array?
-
- Posts: 2
- Joined: Tue May 27, 2014 7:37 pm
- Skillset: PLi
Db2
JCL
Cobol - Referer: via website
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: Builtin Function to get total size of a dynamic array?
You will find no such function ...
when You code something like
once pl1 has allocated the <array>
to keep track of the max indexes values is up to You
if LOC as in common jargon means Lines Of Code
how will the knowledge of the % used for controlled things
reduce the LOC ???
when You code something like
Code: Select all
****** ***************************** Top of Data ******************************
000001 Alloc:
000002 Proc Options(Main);
000003 dcl pliretc builtin;
000004 dcl 1 arr(*) ctl,
000005 5 num fixed bin(31) ;
000006 dcl dim fixed bin(31) init(200);
000007 allocate arr(dim);
000008 call pliretc(0) ;
000009 End;
****** **************************** Bottom of Data ****************************
once pl1 has allocated the <array>
to keep track of the max indexes values is up to You
I am searching for builtin function to reduce LOC!
if LOC as in common jargon means Lines Of Code
how will the knowledge of the % used for controlled things
reduce the LOC ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Builtin Function to get total size of a dynamic array?
Because, enrico, function domagic() can hide literally several lines of code. Thus reducing the overall LOC. domagic() uses lots more CPU, but the bean-counters are concerned about LOC 

-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: Builtin Function to get total size of a dynamic array?
as usual it a problem of the carrot and the stick ...
a high LOC will show a high productivity
but the same will make the maintenance budget forecast larger
a high LOC will show a high productivity
but the same will make the maintenance budget forecast larger
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
- prino
- Posts: 641
- Joined: Wed Mar 11, 2009 12:22 am
- Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
- Referer: Google
- Location: Vilnius, Lithuania
- Contact:
Re: Builtin Function to get total size of a dynamic array?
sathyanandak wrote:I was try to find if any builtin function to get current size of all elements in total of a dynamic array allocated using controlled storage class. I am searching for builtin function to reduce LOC!
enrico-sorichetti wrote:You will find no such function ...
{snip}
once pl1 has allocated the <array>
to keep track of the max indexes values is up to You
CSTG (aka CURRENTSTORAGE, or as it's now called, CURRENTSIZE) will tell you, and if you
Code: Select all
dcl array(i:j) fixed bin (31) ctl;
dcl (i,j) fixed bin (31);
i = 42;
j = 53:
alloc array;
the LBOUND, HBOUND and DIM builtins will all return the correct values. PL/I internally keeps track of every bound, dimension, length, etc of controlled variables, the programmer just uses the required builtins to find them!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
robert.ah.prins @ the.17+Gb.Google thingy
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: Builtin Function to get total size of a dynamic array?
Thanks Robert,
I read too quickly , misunderstood the question and misworded the reply ...
I had inferred that the TS wanted to know not how much was allocated but how much was used out of the allocated area
so I should have written ( for the original way I saw things )
instead of
anyway the comment about LOC is still valid
here is a snippet according to the revised understanding
( did not even have to write it, it was already there in my set of samples )

I had inferred that the TS wanted to know not how much was allocated but how much was used out of the allocated area
so I should have written ( for the original way I saw things )
to keep track of the max indexes values REACHED is up to You
instead of
to keep track of the max indexes values is up to You
anyway the comment about LOC is still valid
here is a snippet according to the revised understanding
( did not even have to write it, it was already there in my set of samples )
Code: Select all
****** ***************************** Top of Data ******************************
000001 Alloc:
000002 Proc Options(Main);
000003 dcl pliretc builtin;
000004 dcl (i,j) fixed bin(31);
000005 dcl a(i:j) fixed bin(31) ctl;
000006 i=11; j=23;
000007 allocate a;
000008 put skip list(lbound(a,1));
000009 put skip list(hbound(a,1));
000010 put skip list(cstg(a));
000011 put skip list(dim(a));
000012 call pliretc(0) ;
000013 End;
****** **************************** Bottom of Data ****************************
Code: Select all
********************************* TOP OF DATA **********************************
11
23
52
13
******************************** BOTTOM OF DATA ********************************
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Posts: 2
- Joined: Tue May 27, 2014 7:37 pm
- Skillset: PLi
Db2
JCL
Cobol - Referer: via website
Re: Builtin Function to get total size of a dynamic array?
Thanks Enrico
I used your first approach using counter to then use length info and pointer to be passed to calling program for processing.

-
- Similar Topics
- Replies
- Views
- Last post
-
-
Process file/records until a specific total is reached.
by chillmo » Thu Mar 24, 2022 6:18 am » in Syncsort/Synctool - 12
- 3780
-
by sergeyken
View the latest post
Wed Mar 30, 2022 10:12 pm
-
-
- 4
- 3264
-
by socker_dad
View the latest post
Fri Dec 31, 2021 5:28 am
-
- 1
- 5321
-
by Robert Sample
View the latest post
Tue Oct 04, 2022 7:36 pm
-
-
Error invoking java method (array) IGZ0045S
by JgbCobol » Mon Nov 07, 2022 3:54 pm » in Mainframe Java - 2
- 5544
-
by JgbCobol
View the latest post
Tue Nov 08, 2022 12:32 pm
-
-
-
Array processing and Table handling with packed decimal
by rogerstrycova » Tue Oct 26, 2021 3:55 pm » in IBM Cobol - 2
- 1700
-
by Robert Sample
View the latest post
Wed Oct 27, 2021 1:12 am
-