Stepper motor laser sensor input

Do you know how to write code to see if a switch is open or closed? See the IDE example code. this is exactly the same thing.

Paul