Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Use of Static variable for storage purpose

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Fri Feb 22, 2008 3:07 pm    Post subject: Use of Static variable for storage purpose
Reply with quote

Hi,

Can anyone explain me the usage of static varible. Is static varible is only for storage purpose or to keep value. Please explain me with examples. I searched in other forums. But it was not clear.
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Feb 22, 2008 6:02 pm    Post subject:
Reply with quote

Can you provide a link to where you found a reference to the term static variable?
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Feb 22, 2008 7:05 pm    Post subject:
Reply with quote

In your terms, what is the difference between "storage purposes" and "keep a value"?

STATIC vars are a PL/I concept. From a web-link:

Quote:
Storage. PL/I provides a number of storage attributes. The default is AUTOMATIC, which is allocated on entry to a block, possibly with initialization, and freed at exit. STATIC storage exists throughout the life of the program,
Back to top
View user's profile Send private message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 59
Location: home

PostPosted: Fri Feb 22, 2008 8:19 pm    Post subject:
Reply with quote

as saying:static for batch program..automatic for online program.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Feb 22, 2008 8:37 pm    Post subject: Use of Static variable for storage purpose
Reply with quote

Do you mean an Assembler constant (DC)?

Code:

EYECTCHR DC    CL38'HELLO, I AM A CONSTANT, LEAVE ME ALONE'


HTH....

Regards,

Bill
Back to top
View user's profile Send private message
u770624

New User


Joined: 12 Jul 2006
Posts: 2
Location: Blighty

PostPosted: Tue Mar 04, 2008 3:40 am    Post subject: Reply to: Use of Static variable for storage purpose
Reply with quote

Illustration on use of static variables ...
Module_A calls Module_B ( and it can do so many times )
Module_B needs to know when it is called for the first time (probably as an efficiency measure)

Therefore Module_B declares a STATIC variable and initialises it to a known value.

Module_B checks the static variable every time it is called and if it is the known, initiallised value then it is the first time it is called. Module_B then performs the first time logic AND sets the static variable to a different value.
On subsequent calls, the value is no longer the initiallised value.

If it was not a static variable then it would be a dynamic variable and would be set to the initiallised value every time Module_B was called.
Back to top
View user's profile Send private message
Mistermind
Warnings : 2

New User


Joined: 08 Feb 2008
Posts: 46
Location: Dublin

PostPosted: Sun Mar 16, 2008 1:59 am    Post subject:
Reply with quote

Static storage is mapped just once inside the PL/I loadmodule, similar to WORKING-STORAGE variable in cobol. Automatic variables are allocated new storage space each time you invoke the subroutine B, so if your subroutine B declares AUTO variables, your partition will very quickly run out of space. This problem will not arise if STATIC variable is declared. If subroutine needs to ensure a certain value in a static variable, e.g. zero, it can be set each time subroutine gains control.

PL/I STATIC variables are also easier to find in storage, always addressed by register 3.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts GETMAIN / FREEMAIN versus STORAGE OBT... steve-myers PL/I & Assembler 8 Wed Feb 01, 2017 1:45 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us