View previous topic :: View next topic
|
Author |
Message |
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Hi,
I have to retain a variable value , if i come out from a module.
For example.
A is calling B.
B is calling C.
In module C I need to perform some paragraph only once, that is when i entered first time into the module C. If i came to module 'C' next time i should not perform that paragraph. For this I did
I have declared a variable as extern.
Module c:
DCL Flag char(1) extern;
If flag not= 'Y' then
do process;
flag = 'Y';
end;
do next process;
return;
When i am coming first time from module B to C, flag is not having any value it is executed, i return back to B i did some process and return back to A. This process is in loop. I came next time to b, b once again called to C, by this time flag didn't have value 'Y'. As of extern or static it should have value until end of the unit.
Please let me know if any other way we can achieve this. with out doing any changes in module 'A'. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Code: |
dcl first bit(1) init('1'b) static;
if first then
do;
first = '0'b;
whatever-else...
end;
|
Should be OK.
Might need special compiler options if this needs to be re-entrant. |
|
Back to top |
|
|
bauer
New User
Joined: 03 Mar 2009 Posts: 28 Location: germany
|
|
|
|
Or use a controlled variable in modul C and builtion function allocation to check if the variable was initialized already. |
|
Back to top |
|
|
|