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

Retain the variable value in PL1


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

New User


Joined: 23 May 2007
Posts: 26
Location: hyderabad

PostPosted: Wed Sep 16, 2009 2:20 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


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

PostPosted: Wed Sep 16, 2009 2:54 pm
Reply with quote

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
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Mon Sep 21, 2009 12:23 pm
Reply with quote

Or use a controlled variable in modul C and builtion function allocation to check if the variable was initialized already.
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