Portion of Simulator Code
This is a portion of the code from the simulator, in this case the code which implements each input of an AND gate.
-- Logic Element AND Input
global LsChangedOutputs
property leSource
property gate
property inputState
on new me, name, sfx, gate_
set gate = gate_
set inputState = FALSE
LsRegisterInput( name, sfx, me )
end
on LeInputSet me, x
if x = inputState then return
set inputState = x
if inputState then
set the inputsOff of gate = the inputsOff of gate - 1
if the inputsOff of gate = 0 then
append( LsChangedOutputs, gate )
end if
else
set the inputsOff of gate = the inputsOff of gate + 1
if the inputsOff of gate = 1 then
append( LsChangedOutputs, gate )
end if
end if
end