Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1102
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 SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us