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

Scope of STATIC VARIABLE


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

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Tue Feb 28, 2006 3:08 pm
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
jawadshaik
Warnings : 1

New User


Joined: 27 Sep 2005
Posts: 16

PostPosted: Tue Feb 28, 2006 5:58 pm
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
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
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
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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SCOPE PENDING option -check data DB2 2
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top