; ChangeLamp.kix
; Automated lightbulb changer
Dim $R, $O, $N, $S, $I
"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
:GetNewLampBayonet
$N=CreateObject("Lamp.Bayonet")
$N.Push
If $N.IsHot
$S.Toggle
$=RunFingersUnderColdWater(@WKSTA)
If $N.Broken Goto "GetNewLampBayonet" EndIf
EndIf
$O.Rotate(90)
Else ;$O.Type="Edison Screw"
do
$O.Rotate(-180)
until $O.Released
:GetNewLampScrew
$N=CreateObject("Lamp.Screw")
While $N.Loose
$N.Rotate(180)
If $N.IsHot
$S.Toggle
$=RunFingersUnderColdWater(@WKSTA)
If $N.Broken Goto "GetNewLampScrew" EndIf
EndIf
Loop
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