| IBM MAINFRAME HELP & SUPPORT FORUMS Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
surendra_mainframe
Joined: 18 Oct 2005
Posts: 5
|
| Posted: Fri Nov 25, 2005 12:05 pm Post subject: Significance of Static in variable initialization |
|
|
Hi,
What is significance of following:
DCL Var FIXED BIN(15) STATIC INIT(100);
Is it this static like in C language? |
|
| Back to top |
|
nutakkimurali
Joined: 15 Nov 2005
Posts: 22
|
| Posted: Fri Nov 25, 2005 1:25 pm Post subject: Re: Significance of Static in variable initialization |
|
|
Variables declared with the STATIC attribute are allocated storage prior to
program execution. They remain allocated until the program terminates.
Noe it down one more thing that,STATIC is the default for external variables.
Where you want variables to retain their value from one invocation of the procedure to another declare them with the static attribute
DCL Var FIXED BIN(15) STATIC INIT(100);
In above staement the value of Var remains the same throughout the program.
*******************************************************
MAIN: PROCEDURE OPTIONS(MAIN);
DCL 1 STRUCTURE,
2 A FIXED DEC (6,2),
2 B CHAR(20);
.
.
P1: PROC;
DCL Name CHAR(10) STATIC init('muralee');
END P1;
P2: PROC;
DCL LIST(500) FIXED STATIC;
.
END P2;
END MAIN;
*********************************************************
Try to print the value of name in P2 and it'll give you the idea about the STATIC.
Muralee |
|
| Back to top |
|
surendra_mainframe
Joined: 18 Oct 2005
Posts: 5
|
| Posted: Fri Nov 25, 2005 1:31 pm Post subject: Re: Significance of Static in variable initialization |
|
|
| Thanx |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|