| CAP110874 Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Case Statement with array |  
				|  Posted: Sun Jun 14, 2009 3:53 pm |   |  
				| 
 |  
				| Hi folks, I was wondering if anyone had used case statements with arrays. 
 I am receiving a 3 character array from the RS232 and want to compare to see what the command received was.
 
 I have it working with IF as shown below but wondered if there was a more streamline way to do this as I may need up to 20 if statements.
 
 Any suggestions welcome. Thank you.
 
  	  | Code: |  	  | void RS232_projector (void)
 {
 //// compare received string to each option
 strcpy(string2, "POO");
 if(strcmp(inputstring, string2) == 0)   // compare string inputstring to a specific value
 {
 projector_output =0;    // set projector type if it matches
 }
 
 strcpy(string2, "PPA");
 if(strcmp(inputstring, string2) == 0)   // compare string inputstring to a specific value
 {
 projector_output =1;
 }
 
 printf("projector_OUTPUT=%x\r\n", (projector_output));
 }
 
 | 
 |  |