On/off control - Maestro Mini

Hi,

I am trying to use potentiometer as on/off switch so that when the pot is on i can use a second potentiometer to control a servo motor.
i am using Mini Maestro, and i am trying to use the code on the controller’s guide page because i don’t really have experience with programming.

this the code i have so far, and it shows me overflow problem. ( ch0 is servo, ch1 is on/off pot, ch2 pot)

# Set the servo to 4000, 6000, or 8000 depending on an analog input when ch0. pot is on
begin
  1 get_position    # get the value of the pot, 0-1023
  300 less_than

  if   
	2 get_position
  	dup 300 less_than
  	if
  	  4000   # go to 4000 for values 0-299
 	 else
  	  dup 600 less_than
  		  if
    		  6000 # go to 6000 for values 300-599
   	 	  else
   	 	  8000 # go to 8000 for values 600-1023
   		 endif
  	endif
  endif
  0 servo
  drop     # remove the original copy of the pot value
repeat

I would appreciate if someone points to me what i am doing wrong. Thanks

I actually was able to get it to work. I still not sure what was wrong with it earlier.

this is what i did.

#Set the servo to 4000, 6000, or 8000 depending on an analog input when ch0. pot is on
begin 
  1 get_position    # get the value of the pot, 0-1023
  10 less_than
  if   
  pot
  endif
repeat 
 
sub pot 
# Set the servo to 4000, 6000, or 8000 depending on an analog input.
  2 get_position    # get the value of the pot, 0-1023
  dup 300 less_than
  if
    4000   # go to 4000 for values 0-299
  else
    dup 600 less_than
    if
      6000 # go to 6000 for values 300-599
    else
      8000 # go to 8000 for values 600-1023
    endif
  endif
  0 servo
  drop     # remove the original copy of the pot value
return