Your mentality is backwards. You write a script to continually check the state of a device, and then the script does something based on the position of the control.

Code:
;;Basic device script for solo maps
(script continuous devicescript
 (if (= (device_get_position myswitch) 0) ;If
  (device_set_position mydoor 0) ;Then
  (device_set_position mydoor 1) ; Else
 )
)
(Remember, the semicolons denote comments in BSL.)