// we rebuild the sensor list with every invocation, because things change function buildSensorList { local sList is Lexicon(). list SENSORS in SensorList. for s in SensorList { if not sList:HasKey(s:type) { sList:add(s:type, s). } } return sList. } function HasSensor { parameter s. local sList is buildSensorList(). return sList:HasKey(s). } function ReadSensor { parameter s. local sList is buildSensorList(). if not sList:HasKey(s) { return -1. // TODO: is -1 an impossible result for all sensors? I suspect not... } return s:DISPLAY:TOSCALAR. }