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 support@ccsinfo.com

newbie need help with if statement

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



Joined: 05 Jul 2006
Posts: 10

View user's profile Send private message

newbie need help with if statement
PostPosted: Wed Jul 05, 2006 4:41 pm     Reply with quote

ok i want to do something like this, but obviously this does not work like c, so if someone can help me out and give me a good example that'll be great

this is what i wanted to do, but the #if only evaluate to a constant or something.... can someone help me change my code so it'll do the same thing? Thanks in advance

#include <16F877A>



#fuses HS
#fuses NOWDT
#fuses NOPROTECT
#fuses NOLVP
#fuses NODEBUG
#fuses PUT
#fuses NOBROWNOUT

#use delay(clock=20000000)

void main()
{
int8 a;
a=100;
output_c(0);

while(1)
{
output_bit(PIN_C0,1);
output_bit(PIN_C1,1);
output_bit(PIN_C2,1);
output_bit(PIN_C3,1);
delay_ms(500);
#if a>90
output_bit(PIN_C0,0);
#elif a>70
output_bit(PIN_C1,0);
#elif a>50
output_bit(PIN_C2,0);
#elif a>30
output_bit(PIN_C3,0);
#else
a=100;
#endif
a--
delay_ms(500);
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 05, 2006 4:56 pm     Reply with quote

Please read these tutorials on the if-else statement in the C language.

http://cslibrary.stanford.edu/101/EssentialC.pdf
(see page 11)

http://www.its.strath.ac.uk/courses/c/subsection3_8_1.html
sheing3003



Joined: 05 Jul 2006
Posts: 10

View user's profile Send private message

PostPosted: Wed Jul 05, 2006 5:03 pm     Reply with quote

PCM programmer wrote:
Please read these tutorials on the if-else statement in the C language.

http://cslibrary.stanford.edu/101/EssentialC.pdf
(see page 11)

http://www.its.strath.ac.uk/courses/c/subsection3_8_1.html


ok never mind....
i thought you cant use if statement... that's why i use #if...
wow~~ this is amazing! lol
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