Home AMX User Forum NetLinx Studio

unexpected result HELPPP

somebody please help me with this block
[php]
(*Micz 1 - 8 Mute ON/OFF TOGGLE*)
case 87:(*Mics 1*)
case 88:(*Mics 2*)
case 89:(*Mics 3*)
case 90:(*Mics 4*)
case 91:(*Mics 5*)
case 92:(*Mics 6*)
case 93:(*Mics 7*)
case 94:(*Mics 8*)
{
local_var integer nChanID
local_var integer nMicMuteStatus[8]
local_var integer nMicStatLoop
nChanID = (button.input.channel - 183)
for(nMicStatLoop=1;nMicStatLoop<=8;nMicStatLoop++)
if (nMicMuteStatus[nMicStatLoop] = 0)
{
AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nChanID),' ',itoa(nChanID),' ','1',$0A,$FF")
nMicMuteStatus[nChanID] = 1
}
else if (nMicMuteStatus[nMicStatLoop] = 1)
{
AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nChanID),' ',itoa(nChanID),' ','0',$0A,$FF")
nMicMuteStatus[nChanID] = 0
}
}
}
[/php]
it runs through all 8 I only need 1 if event happened, what am i over looking?

Comments

  • ColzieColzie Posts: 470
    You have a FOR loop from 1 to 8?
  • Spire_JeffSpire_Jeff Posts: 1,917
    Why do you have the for loop? That is what is causing it to run 8 times. I am not familiar with the protocol, so I'm not sure if you need to do something 8 times. If you do, the command you are sending out is not changing because you are not changing nChanID within the for loop.

    Jeff
  • avi_daveavi_dave Posts: 62
    even if I do it off the last modified channel like so:-
            (*Micz 1 - 8 Mute ON/OFF TOGGLE*) 
            case 87:(*Mics 1*) 
            case 88:(*Mics 2*) 
            case 89:(*Mics 3*) 
            case 90:(*Mics 4*) 
            case 91:(*Mics 5*) 
            case 92:(*Mics 6*) 
            case 93:(*Mics 7*) 
            case 94:(*Mics 8*)     
            {              
                local_var integer nChanID
                nChanID = (button.input.channel - 183) 
                if (nMicMuteStatus[nChanID ] = 0) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nChanID),' ',itoa(nChanID),' ','1',$0A,$FF")  
                    nMicMuteStatus[nChanID] = 1 
                } 
                else if (nMicMuteStatus[nChanID] = 1) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nChanID),' ',itoa(nChanID),' ','0',$0A,$FF")  
                    nMicMuteStatus[nChanID] = 0 
                    } 
                } 
            } 
    
    if lets say nchanID = 3 like so:-
            (*Micz 1 - 8 Mute ON/OFF TOGGLE*) 
            case 87:(*Mics 1*) 
            case 88:(*Mics 2*) 
            case 89:(*Mics 3*) 
            case 90:(*Mics 4*) 
            case 91:(*Mics 5*) 
            case 92:(*Mics 6*) 
            case 93:(*Mics 7*) 
            case 94:(*Mics 8*)     
            {              
                if (nMicMuteStatus[3] = 0) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(3),' ',itoa(3),' ','1',$0A,$FF")  
                    nMicMuteStatus[3] = 1 
                } 
                else if (nMicMuteStatus[3] = 1) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(3),' ',itoa(3),' ','0',$0A,$FF")  
                    nMicMuteStatus[3] = 0 
                    } 
                } 
            } 
    
    same ending result.....
  • Spire_JeffSpire_Jeff Posts: 1,917
    Maybe I'm not understanding what you want it to do. Do you have diagnostics that show what is being sent? If so, what should be getting sent?

    The only other thing I can see is that you are talking about the first Case statements. If you don't want mics 1-7 to hit the code, you need to either remove them from the code, or make them do nothing like such:
            case 87:(*Mics 1*) 
            case 88:(*Mics 2*) 
            case 89:(*Mics 3*) 
            case 90:(*Mics 4*) 
            case 91:(*Mics 5*) 
            case 92:(*Mics 6*) 
            case 93:(*Mics 7*) 
            {
               //Add this code Later
            }
            case 94:(*Mics 8*)
    . 
    .
    .
    
    

    This is actually a feature that it lets you declare multiple cases for the same block of code.

    Jeff
  • avi_daveavi_dave Posts: 62
    yeah I know i could just break it up in pieces, but I was trying to stack it and do like a get_last type modified button, for example, this block of code work flawlessy for every install :-
    			(*Polycom Remote Simulation*)
    			case 1://{pulse[vdvPolycomVSX,10]}//Keypad 0	// DO NOT DELETE !!
    			case 2://{pulse[vdvPolycomVSX,11]}//Keypad 1	//
    			case 3://{pulse[vdvPolycomVSX,12]}//Keypad 2	//
    			case 4://{pulse[vdvPolycomVSX,13]}//Keypad 3	//
    			case 5://{pulse[vdvPolycomVSX,14]}//Keypad 4	// REMOTE EMULATION WITHOUT TOUCHPANEL FEEDBACK COMMENT LINEZ
    			case 6://{pulse[vdvPolycomVSX,15]}//Keypad 5	// AS NEEDED IF YOU ONLY NEED THIS FEATURE!!!!!
    			case 7://{pulse[vdvPolycomVSX,16]}//Keypad 6	//
    			case 8://{pulse[vdvPolycomVSX,17]}//Keypad 7	//
    			case 9://{pulse[vdvPolycomVSX,18]}//Keypad 8	//
    			case 10://{pulse[vdvPolycomVSX,19]}//Keypad 9	// DO NOT DELETE !!
    			case 11://Keypad Asterick
    			case 12://Keypad Pound
    			case 13://Keypad Period/Star ( . )
    				(* Keypad with touchpanel feedback*)
    				{
    					select
    					{
    						active((button.input.channel >=1)&&(button.input.channel <=10)):
    						{
    							cPolycom_key = itoa(button.input.channel - 1)
    						}
    						active(1):
    						{
    							select
    							{
    								active(button.input.channel = 13):{cPolycom_key = '*'}
    								active(button.input.channel = 12):{cPolycom_key = '#'}
    								active(button.input.channel = 11):{cPolycom_key = ','}
    							}
    						}
    					}
    					cPolycom_Num = "cPolycom_Num,cPolycom_key" //append to key to string
    					//send_command vdvPolycomVSX,"'DIALNUMBER-',itoa(cPolycom_Num)" //send string to module
    					send_command dvTP_VTC,"'^TXT-18,0, ',cPolycom_Num"	//send string to panel
    				}
    
    so thinking would apply the same concept on the last modified but put that on the table and send it not all the grimlins.
  • ColzieColzie Posts: 470
    I would try this and see what Diagnostics reports...
            (*Micz 1 - 8 Mute ON/OFF TOGGLE*) 
            case 87:(*Mics 1*) 
            case 88:(*Mics 2*) 
            case 89:(*Mics 3*) 
            case 90:(*Mics 4*) 
            case 91:(*Mics 5*) 
            case 92:(*Mics 6*) 
            case 93:(*Mics 7*) 
            case 94:(*Mics 8*)     
            {              
                send_string 0, "'button.input.channel=', button.input.channel"
                
                if (nMicMuteStatus[3] = 0) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(3),' ',itoa(3),' ','1',$0A,$FF")  
                    nMicMuteStatus[3] = 1 
                } 
                else if (nMicMuteStatus[3] = 1) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(3),' ',itoa(3),' ','0',$0A,$FF")  
                    nMicMuteStatus[3] = 0 
                    } 
                } 
            } 
    

    Is your entire switch/case in a FOR loop? Can you give more details on exactly what is happening 8 times?
  • DHawthorneDHawthorne Posts: 4,584
    Your cases are stacked. A bizarre NetLinx construction leftover from Axcess that no other programming language I am familiar with allows ... the only thing separating your cases are comments, so it treats them as if you want the same thing to happen for each one (just like stacking PUSH statements). Put an empty set of braces {} after each case, or a BREAK statement, and it will only fire one per pass.
  • ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    Your cases are stacked. A bizarre NetLinx construction leftover from Axcess that no other programming language I am familiar with allows ... the only thing separating your cases are comments, so it treats them as if you want the same thing to happen for each one (just like stacking PUSH statements). Put an empty set of braces {} after each case, or a BREAK statement, and it will only fire one per pass.


    I agree that the CASE: stack (and other stacks available for us to use) are bizzare. But, I hope they keep them. I do use them all the time. I wish they were allowable in some other languages I have to peck through.
  • ColzieColzie Posts: 470
    DHawthorne wrote: »
    Your cases are stacked. A bizarre NetLinx construction leftover from Axcess that no other programming language I am familiar with allows ... the only thing separating your cases are comments, so it treats them as if you want the same thing to happen for each one (just like stacking PUSH statements). Put an empty set of braces {} after each case, or a BREAK statement, and it will only fire one per pass.

    Unless I'm misunderstanding he actually wants all of the cases to trigger the same code block.

    I agree, I hope they keep this "feature" as I use it quite often.
  • avi_daveavi_dave Posts: 62
    lemmi explain it this way, yes I do want the same code to execute for any of the 8, but substitute like so:-

    if mic 5
    (*Micz 1 - 8 Mute ON/OFF TOGGLE*) 
            case 87:(*Mics 1*) 
            case 88:(*Mics 2*) 
            case 89:(*Mics 3*) 
            case 90:(*Mics 4*) 
            case 91:(*Mics 5*) 
            case 92:(*Mics 6*) 
            case 93:(*Mics 7*) 
            case 94:(*Mics 8*)     
            {              
                if (nMicMuteStatus[(*Mics 5*) ] = 0)  //element 5 = 0
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa((*Mics 5*) ),' ',itoa((*Mics 5*) ),' ','1',$0A,$FF")  //fdr 5 channel 5
                    nMicMuteStatus[(*Mics 5*) ] = 1 
                } 
                else if (nMicMuteStatus[(*Mics 5*) ] = 1) 
                { 
                    AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa((*Mics 5*) ),' ',itoa((*Mics 5*) ),' ','0',$0A,$FF")  //fdr 5 channel 5
    
                    nMicMuteStatus[(*Mics 5*) ] = 0 //element 5 = 0
                    } 
                } 
            }
    

    or the longer way I gave up grrrrrr
    		(*Micz 1 - 8 Mute ON/OFF TOGGLE*)
    		case 87:(*Mics 1*)
    		case 88:(*Mics 2*)
    		case 89:(*Mics 3*)
    		case 90:(*Mics 4*)
    		case 91:(*Mics 5*)
    		case 92:(*Mics 6*)
    		case 93:(*Mics 7*)
    		case 94:(*Mics 8*)    
    		{             
    			local_var integer nMicMuteStatus[8]
    			select
    			{
    				active((nMicMuteStatus[1] = 0)&&(button.input.channel = 87)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 1 1 1',$0A,$FF")nMicMuteStatus[1] = 1
    				}
    				active((nMicMuteStatus[2] = 0)&&(button.input.channel = 88)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 2 2 1',$0A,$FF")nMicMuteStatus[2] = 1
    				}
    				active((nMicMuteStatus[3] = 0)&&(button.input.channel = 89)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 3 3 1',$0A,$FF")nMicMuteStatus[3] = 1
    				}
    				active((nMicMuteStatus[4] = 0)&&(button.input.channel = 90)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 4 4 1',$0A,$FF")nMicMuteStatus[4] = 1
    				}
    				active((nMicMuteStatus[5] = 0)&&(button.input.channel = 91)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 5 5 1',$0A,$FF")nMicMuteStatus[5] = 1
    				}
    				active((nMicMuteStatus[6] = 0)&&(button.input.channel = 92)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 6 6 1',$0A,$FF")nMicMuteStatus[6] = 1
    				}
    				active((nMicMuteStatus[7] = 0)&&(button.input.channel = 93)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 7 7 1',$0A,$FF")nMicMuteStatus[7] = 1
    				}
    				active((nMicMuteStatus[8] = 0)&&(button.input.channel = 94)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 8 8 1',$0A,$FF")nMicMuteStatus[8] = 1
    				}
    				active((nMicMuteStatus[1] = 1)&&(button.input.channel = 87)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 1 1 0',$0A,$FF")nMicMuteStatus[1] = 0
    				}
    				active((nMicMuteStatus[2] = 1)&&(button.input.channel = 88)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 2 2 0',$0A,$FF")nMicMuteStatus[2] = 0
    				}
    				active((nMicMuteStatus[3] = 1)&&(button.input.channel = 89)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 3 3 0',$0A,$FF")nMicMuteStatus[3] = 0
    				}
    				active((nMicMuteStatus[4] = 1)&&(button.input.channel = 90)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 4 4 0',$0A,$FF")nMicMuteStatus[4] = 0
    				}
    				active((nMicMuteStatus[5] = 1)&&(button.input.channel = 91)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 5 5 0',$0A,$FF")nMicMuteStatus[5] = 0
    				}
    				active((nMicMuteStatus[6] = 1)&&(button.input.channel = 92)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 6 6 0',$0A,$FF")nMicMuteStatus[6] = 0
    				}
    				active((nMicMuteStatus[7] = 1)&&(button.input.channel = 93)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 7 7 0',$0A,$FF")nMicMuteStatus[7] = 0
    				}
    				active((nMicMuteStatus[8] = 1)&&(button.input.channel = 94)):
    				{
    					AddtoNexiaQue("'SET 1 FDRMUTE 8 8 0',$0A,$FF")nMicMuteStatus[8] = 0
    				}
    
  • ericmedleyericmedley Posts: 4,177
    could you please put up the entire hunk of code that the CASE statements are in. one of the difficulties is that it's hard to see what you're trying to do without it.
  • viningvining Posts: 4,368
    Are you trying to do something like this?
    BUTTON_EVENT [dvMics,nMicBtnArry]      
         
         {
         PUSH:
    	  {
    	  STACK_VAR INTEGER nMicBtn ;
    	  
    	  nMicBtn = GET_LAST(nMicBtnArry) ;
    	  SELECT 
    	       {
    	       ACTIVE(nMicBtn >= 1 && nMicBtn <= 86):
    		    {
    		    //stuff
    		    }
    	       ACTIVE(nMicBtn >= 87 && nMicBtn <= 94):
    		    {
    		    SWITCH(nMicBtn)
    			 {
    			 case 87:(*Mics 1*) 
    			 case 88:(*Mics 2*) 
    			 case 89:(*Mics 3*) 
    			 case 90:(*Mics 4*) 
    			 case 91:(*Mics 5*) 
    			 case 92:(*Mics 6*) 
    			 case 93:(*Mics 7*) 
    			 case 94:(*Mics 8*)     
    			      { 
    			      STACK_VAR INTEGER nMic ;
    			      
    			      nMic = nMicBtn - 86 ;
    			      if (nMicMuteStatus[nMic] == 0)  
    				   { 
    				   AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nMic),' ',itoa((nMic),' ','1',$0A,$FF")  //fdr 5 channel 5
    				   nMicMuteStatus[nMic] = 1 
    				   } 
    			      else if (nMicMuteStatus[nMic] == 1) 
    				   { 
    				   AddtoNexiaQue("'SET 1 FDRMUTE',' ',itoa(nMic),' ',itoa(nMic),' ','0',$0A,$FF")  //fdr 5 channel 5
    				   nMicMuteStatus[nMic] = 0 
    				   } 
    			      } 
    			 }
    		    }
    	       ACTIVE(nMicBtn >= 95 && nMicBtn <= 120):
    		    {
    		    //stuff
    		    }
    	       }
    	  }
         }
    

    And don't put comments in your braces cuz that really messed with my head!
    if (nMicMuteStatus[(*Mics 5*) ] = 0
    
  • avi_daveavi_dave Posts: 62
    awesome, I think I messed up at the == 0, where I was telling it to = 0 awesome dude awesome thanx
  • ColzieColzie Posts: 470
    avi_dave wrote: »
    awesome, I think I messed up at the == 0, where I was telling it to = 0 awesome dude awesome thanx

    I have never had an issue using = where == is technically correct. Anyone else?

    I've started trying to use == because it is the proper way, and it can also make the code easier to read - especially with things like
    [dv_TP1, 1] = (i_bla == 1)
    
  • viningvining Posts: 4,368
    Yeah = is supposed to be ok but I can't bring myself to use it for comparisons.
Sign In or Register to comment.