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