Click here to Skip to main content
15,904,935 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a console program. I want to create a flag that can be set from one part of the code and checked by another part of the code. I assume that this is some type of variable, but how do I set and unset this flag? Thank you.
Posted
Comments
Ed Nutting 6-Oct-11 2:25am    
Try using a boolean variable for the flag and place it where all the code that needs to can access it. Possibly in some form of class that gets passed around/stored? Hope this helps,
Ed :)
Member 7766180 6-Oct-11 3:17am    
Thank you Edward. boolean it is. It's the passing around and storing that confuses me!
Richard MacCutchan 6-Oct-11 3:54am    
If it's in a class then you make sure the object containing it gets passed around from method to method. Alternatively (and not recommended) for a simple program you could use a global variable.
Member 7766180 6-Oct-11 13:45pm    
Bingo! That's simple enough! Thank you. Put it in a solution. Give Credit!

1 solution

Richard MacCutchan - 6 Oct '11
If it's in a class then you make sure the object containing it gets passed around from method to method. Alternatively (and not recommended) for a simple program you could use a global variable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900