MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reg Astrick (*) - PL/1

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
key
Beginner


Joined: 29 Dec 2005
Posts: 19
Topics: 6

PostPosted: Fri Mar 03, 2006 2:31 am    Post subject: Reg Astrick (*) - PL/1 Reply with quote

Hi,

Following is my PL - 1 program.
Code:

 OPTIONAL : Procedure options (MAIN);
  DCL A(20) CHAR(1) ;
  DCL SUB1 ENTRY;
  CALL SUB1(A);
 End  OPTIONAL;

 SUB1:PROC(A);
  DCL A(*)  CHAR(1);
  DCL NAME  CHAR(10);
  DCL VALUE FIXED DEC;

  PUT SKIP LIST(DIM(A));

  PUT LIST('ENTER YOUR NAME');
  GET LIST(NAME);
  VALUE = LENGTH(NAME);

  DO I = VALUE TO 1 BY -1;
     A(I) = SUBSTR(NAME,I,1);
     PUT EDIT(A(I))(A(1));
  END;
    PUT SKIP LIST(DIM(C));
 END SUB1;

My output is
  PUT SKIP LIST(DIM(C)); ----> 20
  PUT EDIT(C(I))(A(1));    -----> my reversed string
  PUT SKIP LIST(DIM(C)); ----> 20

My question is,
what is the significance for using A(*) in my sub procedure ?
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Fri Mar 03, 2006 4:24 am    Post subject: Reply with quote

key, from the manual:

Quote:
An asterisk (*) specifies that the lower and/or the upper bound is taken from the argument associated with the parameter.



http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/C2714602/8.7.1?SHELF=&DT=20020917160741
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
key
Beginner


Joined: 29 Dec 2005
Posts: 19
Topics: 6

PostPosted: Fri Mar 03, 2006 4:47 am    Post subject: Reply with quote

Thanks for the reply.
Let me explain the question elaborately.

In my declaration i have given
DCL A(20) CHAR(1) ;

in SUB1 proc call I am using this Array variable like follows

DCL A(*) CHAR(1) ;

Here (*) is getting the value of 20 (dimension). And i have used in my SUB1 proc only 6 char to reverse it.

My questions are,
Is that (*) will reduce my storage utilization depends upon my usage?
or
(*) will be used only for dynamically allocating the value for the array with in the lower and upper limits of 1 to 20 [becoz my declaration in the main program is A(20)]?

Kindly let me know.
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Fri Mar 03, 2006 9:48 am    Post subject: Reply with quote

The array is allocated in the caller. The subroutine does not allocate any storage for it. The reason for using (*) is so that you can pass in arrays of different length, possibly from different programs and the generic subroutine will still work (though yours will not work if the array length is < 10 since you never check that your loop doesn't write past the length of the array).
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group