Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Scope of STATIC VARIABLE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & ASSEMBLER
Author Message
nutakkimurali

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Tue Feb 28, 2006 3:08 pm    Post subject: Scope of STATIC VARIABLE
Reply with quote

If i declare soemthing like below what is the output

MAIN : PROC OPTIONS(MAIN)
DCL A FIXED DEC(5,2) STATIC INIT('5');
B FIXED DEC(5,2) STATIC INIT('8');
.
.

.

Q : PROC
DCL A FIXED DEC(5,2) STATIC INIT('7');
PUT SKIPLIST ('A');
END Q;
Z : PROC
B FIXED DEC(5,2) INTERNAL STATIC INIT('9');
PUT SKIPLIST ('B');
END Z;
END MAIN;

I want to know what is the value of A when Q invokes and what is the value of B when Z invokes where B is declared as INTERNAL STATIC?

Plz help me on this

Regards,
Muralee
Back to top
View user's profile Send private message
References
jawadshaik
Warnings : 1

New User


Joined: 27 Sep 2005
Posts: 16

PostPosted: Tue Feb 28, 2006 5:58 pm    Post subject: Re: Scope of STATIC VARIABLE
Reply with quote

hi

the values will be 7 and 9 respectively.
Back to top
View user's profile Send private message
nutakkimurali

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Tue Feb 28, 2006 6:09 pm    Post subject: Re: Scope of STATIC VARIABLE
Reply with quote

jawadshaik wrote:
hi

the values will be 7 and 9 respectively.



Thank you...
Back to top
View user's profile Send private message
nutakkimurali

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Thu Mar 02, 2006 2:46 pm    Post subject: Re: Scope of STATIC VARIABLE
Reply with quote

[MAIN : PROC OPTIONS(MAIN)
DCL A FIXED DEC(5,2) STATIC INIT('5');
B FIXED DEC(5,2) STATIC INIT('8');
.
.

.

Q : PROC
DCL A FIXED DEC(5,2) EXTERNAL STATIC INIT('7');
PUT SKIPLIST ('A');
END Q;
Z : PROC
B FIXED DEC(5,2) INTERNAL STATIC INIT('9');
PUT SKIPLIST ('B');
END Z;
END MAIN;
If i declare something as External in Proc Q and what is the output even though i declare the same variable in MAIN proc ???

Please let me know
Back to top
View user's profile Send private message
jawadshaik
Warnings : 1

New User


Joined: 27 Sep 2005
Posts: 16

PostPosted: Thu Mar 02, 2006 4:14 pm    Post subject:
Reply with quote

hi

the values will be 7 and 9 respectively

if static is mentioned the value the variable is having before leaving the proc will be given at the time the control again comes to the proc.

Q : PROC
DCL A FIXED DEC(5,2) EXTERNAL STATIC INIT('7');
PUT SKIPLIST ('A');
a = 10;
END Q;

call Q;
call Q;

for first call of Q a will be displayed as 7 next time when it is called the value displayed will be 10

hope you go what i was trying to convey

with reagrds,

Jawad shaik
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & ASSEMBLER All times are GMT + 6 Hours
Page 1 of 1