; ChangeLamp.kix
; Automated lightbulb changer
Dim $R, $O, $N, $S, $I, $M
"Please enter lightbulb maintenance reference: " Gets $R
$O=GetObject("Lamp://"+$R)
$S=GetObject("Switch://"+$R)
$S.Toggle
$I=$OState | $O.Illuminated
$S.Toggle
If $I
If $O.Type="Bayonet"
$O.Push
$O.Rotate(-90)
$O.Pull
Do
$N=CreateObject("Lamp.Bayonet")
$N.Push
If $N.IsHot
$S.Toggle
$=RunFingersUnderColdWater(@WKSTA)
EndIf
Until NOT $N.Broken
$O.Rotate(90)
Else ;$O.Type="Edison Screw"
Do
$O.Rotate(-180)
until $O.Released
Do
$N=CreateObject("Lamp.Screw")
While $N.Loose
$N.Rotate(180)
If $N.IsHot
$S.Toggle
$=RunFingersUnderColdWater(@WKSTA)
EndIf
Loop
Until Not $N.Broken
EndIf
$S.Toggle
If $OState | $O.Illuminated
"Lamp successfully changed and tested"+@CRLF
Else
"Lamp still not working. Please try running FixFuse.kix then retry ChangeLamp.kix"+@CRLF
EndIf
$S.Toggle
Else
"Lamp is OK, no need to change"+@CRLF
EndIf