View previous topic :: View next topic |
Author |
Message |
key Beginner
Joined: 29 Dec 2005 Posts: 19 Topics: 6
|
Posted: Fri Mar 03, 2006 2:31 am Post subject: Reg Astrick (*) - PL/1 |
|
|
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 |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
|
Back to top |
|
 |
key Beginner
Joined: 29 Dec 2005 Posts: 19 Topics: 6
|
Posted: Fri Mar 03, 2006 4:47 am Post subject: |
|
|
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 |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Fri Mar 03, 2006 9:48 am Post subject: |
|
|
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 |
|
 |
|
|