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
 

 

Retain the variable value in PL1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: Retain the variable value in PL1
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: 1031
Location: Oostende, Belgium

PostPosted: Wed Sep 16, 2009 2:54 pm    Post subject:
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: 26
Location: germany

PostPosted: Mon Sep 21, 2009 12:23 pm    Post subject: Reply to: Retain the variable value in PL1
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    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 Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
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


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