Here you go. I did this for another thread that wanted the same thing. There are 3 samples for moving an object within a limited range.
Left is easy and acrurate enough I think for most slide switches
middle is finicky but in there just to show how to use the touch for it
Right uses the drag and drop and moves the object between two points
also the capx was written for Y angle, so make adjustements as needed.