CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

while

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wahid



Joined: 02 May 2013
Posts: 5

View user's profile Send private message Send e-mail

while
PostPosted: Fri May 03, 2013 6:16 pm     Reply with quote

I have a question PIC C compile.
  how to exit the while loop condition because the break problem unconditionally
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri May 03, 2013 6:28 pm     Reply with quote

sorry, but this does not make sense for me.

break;

IS the unconditional way out of while

if (condition) break;

is the conditional way.


also return;
IF you not in main();
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 03, 2013 7:47 pm     Reply with quote

jeremiah has an example of breaking out of a while loop here:
http://www.ccsinfo.com/forum/viewtopic.php?t=47894&highlight=break&start=11
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Sat May 04, 2013 3:25 am     Reply with quote

This is actually nothing to do with 'PIC C', but is just standard C...

You have three things in a while loop.
First, the standard 'exit' condition evaluated each time the loop executes.
Then 'continue', which forces this evaluation to occur immediately.
Finally 'break' which exits the loop without testing the exit condition.

Both continue, and break, can themselves be executed with a test.

You have already been given examples of using 'break' with tests. The other method is using 'continue', so:
Code:

int1 loop=TRUE;

   while (loop)
   {
       //do what you want
       if (some exit condition)
       {
           loop=FALSE;
           continue;
       }
       //and more of what you want
    }


Here, a 'test' changes the looping condition to 'FALSE', and forces an immediate re-test of the loop condition.

Best Wishes
wahid



Joined: 02 May 2013
Posts: 5

View user's profile Send private message Send e-mail

PostPosted: Sat May 04, 2013 9:44 am     Reply with quote

my problem I use a 4 * 4 keypad and display. Each button has a function and this function when the data REGARDLESS while loop and complaint in this button.
example temperature value button button to happiness
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat May 04, 2013 11:30 am     Reply with quote

then post that code and lets look at it's structure.
wahid



Joined: 02 May 2013
Posts: 5

View user's profile Send private message Send e-mail

PostPosted: Sat May 04, 2013 6:32 pm     Reply with quote

such as phone button click button gives 3la result on screen when button function with while
when I click given function but when I click has another button without complaint while not.

thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group