kenneth er

If...Else Statement not working properly

Discussion created by kenneth er on Jun 6, 2006
Latest reply on Jun 8, 2006 by Guest
Krude here. I am experiencing problem with the If...Else statement. I know it's very simple but I not sure why that after the condition match, the program would not go into the code but jump out of the If....Else statement. Attached below is my code*no modification done*. The statement works on my main code body but not after I place it on another file, so I can use it as an object. Thanks for helping me out. Arigatou!

#include "derivative.h"
#include "M68DEMO908GB60" /*customized header file for GB60DEMO board*/
#include "timer.h" //customized header file for timer
#include "leds.h" //customized header file for LED
#include "sine.h" //customized header file for sine wave
#include "dac.h"
#include "swtiches.h"

int ichoice;
int iTimActPerioddef;

int swit::check (void){

int iwaitmain=0, iSW2flag, iSW3flag,FFreqFlag=0;

timer2 Timer1;

if(SW4 == DOWN){ //SW1 start the data transfer process

iTimActPerioddef = 96;
FFreqFlag = 0;
}else if (ichoice>31){
FFreqFlag = 1;

} else if (SW2 == DOWN){ //SW2 increase the frequency

iSW2flag = 1;//the flag will be set when SW2 is pressed down. Flag is to prevent multi-increment of the ichoice

} else if(iSW2flag == 1 && SW2 == UP){

if(ichoice 36){
ichoice ++;
iSW2flag = 0;

} else if(SW3 == DOWN){ //SW3 decrease the frequency

iSW3flag = 1;//the flag will be set when SW2 is pressed down. Flag is to prevent multi-decrement of the ichoice

} else if(iSW3flag == 1 && SW3 == UP) {

if(ichoice > 0){
ichoice --;
iSW3flag = 0;
} else{

return FFreqFlag;