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

Static variable are global ?


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

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Tue May 11, 2010 3:09 pm
Reply with quote

If I have a main proc called M,
In M, I have A proc and B proc.
Now, if I declare a variable 'x' in A proc as Static. Can I use it in the main proc M without having declared it in M ??

If not, then please let me know, is there anything like global variable where the above should be possible.

Please advice.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Tue May 11, 2010 3:32 pm
Reply with quote

No.

Variables are only know in the procedure in which they are declared and in all procedures contained in that procedure. Whether they are STATIC or AUTOMATIC has absolutely no relevance.

If you want a global variable, declare it in the outermost block, and it will be visible in all internal procedures, unless any of the internal procedures declares a variable with the same name, in which case you have no way of accessing the same named variable in the outer procedure.
Back to top
View user's profile Send private message
donateeye
Warnings : 2

New User


Joined: 01 Jun 2007
Posts: 62
Location: chennai

PostPosted: Tue May 11, 2010 3:36 pm
Reply with quote

Great... Thanks a lot Prino
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 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
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top