#178087 - 2007-07-19 04:51 PM
Re: How Many Members
[Re: Lonkero]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#178091 - 2007-07-19 05:59 PM
Re: How Many Members
[Re: Arend_]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
My golfing attempt:
; 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
|
Top
|
|
|
|
#178102 - 2007-07-20 03:43 AM
Re: How Many Members
[Re: Lonkero]
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
disciplinarian would result in 4 ... but no that would be a Jens only forum There's no need to discipline you, my disciples, ahem, children,...
Q: How many Germans does it take to screw in a light bulb? A: Ve are asking ze qvestions here!
Q: How many Germans does it take to screw in a light bulb? A: Two, one to give the order that the bulb be changed and one to screw it in.
Q: How many Germans does it take to screw in a light bulb? A: None. They assign the task to a gastarbeiter.
Q: Helga, how many Germans does it take to change a light bulb? A: Ah, is this the one about the highly-trained quality control checkers at the Löwenbräu brewery here in the beautiful city of Munich where they have to carefully check that each and every stage of the beer brewing process adheres to the Reinheitsgebot ancient brewing laws laid down in 1516 which set minimum standards for the purity of the ingredients otherwise they'd be subject to extremely enormous fines so quality control is a very important job both in terms of the quality of all the Löwenbräu beers and of course the financial good health of the company from the checking of the malted barley with the hops not forgetting the pure Bavarian spring water by any chance? What we Germans lack in humour, we make up for in our beer.
Source: The ultimate lightbulb joke list at http://bulbs.justpickone.org/lbbase.html.gz
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#178105 - 2007-07-20 09:25 AM
Re: How Many Members
[Re: Sealeopard]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Might I suggest $S.Toggle(0) for turning off then
In the interest of maintining the level of pedantry in this thread - No, you may not
Maybe it doesn't translate very well into other languages, but "Toggle" in english when used in a programming context means "change to the alternate state".
For booleans, it has the same effect as NOT, so the following two statements are equivalent:
1 - $oSwitch.State=Not $oSwitch.State
2 - $oSwitch.Toggle
For a 1Hz (2Hz? someone help me out) flashing lamp effect:
while "true"
$oSwitch.Toggle
Sleep 0.5
Loop
Perhaps I should have described the script better as a "lightbulb change emulator", as it emulates what people do, rather that the sensible way of doing it which would have been less amusing - people burning their fingers through ineptitude is always going to be funny.
When a bulb doesn't work, people tend to flick (toggle) the switch two or three times before the fact that it is clearly not working sinks in. Then they change the bulb, forgetting to check the state of the lightswitch first.
Now, you could check $oSwitch.State at the start and toggle the switch if true. This would allow you to remove the later IsHot checks and and lose the entire RunFingersUnderColdWater() UDF making the code much shorter.
However, the problem with this is twofold:
- Push type switches often don't have a clear on/off state, so $oSwitch.State will be undetermined.
- Another routine may have toggled the switch state after you checked it. You can get around this if the switch supports the "Lock" method, but most lamp switches do not.
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 918 anonymous users online.
|
|
|