Home AMX User Forum AMX General Discussion

Quick question:

Under Define Function fn ProjInput()
{
IF(nSource = 3 ) //PC
{
sProjTxBuf = "sProjTxbuf,sProj_cmds[3]" // RGB INPUT
}
Else
{
sProjTxBuf = "sProjTxbuf,sProj_cmds[5]" // Video Input

Basically can I amend the IF line to read= 3,4)
In other words can I have it go to sProj_cmds[3] with either input ??

Thanks for the input

Comments

  • viningvining Posts: 4,368
    Define Function fnProjInput()
         
         {
         if(nSource == 3 || nSource == 4) // = will work but == is a clearer meaning
    	  {
    	  //do something ;
    	  }
         
    
    
    or 
    
    Define Function fnProjInput()
         
         {
         if(nSource > 2 && nSource < 5) 
    	  {
    	  //do something ;
    	  }
         
    or 
    
    Define Function fnProjInput()
         
         {
         SWITCH(nSource)
    	  {
    	  CASE 1:
    	       {
    	       //do something for source 1
    	       }
    	  CASE 2:
    	       {
    	       //do something for source 2
    	       }
    	  CASE 3:
    	  CASE 4:
    	       {
    	       //do something for source 3 or 4
    	       }
    	  }
    
    or
    
    Define Function fn ProjInput()
         
         {
         SELECT
    	  {
    	  ACTIVE(nSource == 1):
    	       {
    	       //do something for source 1
    	       }
    	  ACTIVE(nSource == 2):
    	       {
    	       //do something for source 2
    	       }
    	  ACTIVE(nSource == 3 || nSource == 3):
    	       {
    	       //do something for source 3 or 4
    	       }
    	  }
    	  
    
  • MWNE2MWNE2 Posts: 15
    Thanks, I was fairly sure I could , just wanted to throw it at the wall and see if it stuck.
  • Wow, that code looks familiar.
  • DHawthorneDHawthorne Posts: 4,584
    Even when it is possible to make such a conditional work with an IF...ELSE, I will frequently put it in the form of a SWITCH...CASE or SELECT...ACTIVE (depending on the condition tested) just so it is easily expandable if the project changes in the future. Both branching statements support default condition (DEFAULT: for a SWITCH, and ACTIVE(TRUE) for a SELECT), and sometimes I'll even make one where that is the only choice. Nested IF's are a royal pain to keep track of and maintain, where you can cut and paste ACTIVE or CASE lines and add them in very easily. If there is ever more than one choice, or any possibility the conditional might need to be expanded, that is the way I go.
  • MWNE2MWNE2 Posts: 15
    Tony, it should you had a MAJOR part in it.
    thanks again.
    Mark
Sign In or Register to comment.