I have been working on this for far too long, mostly going in circles. I have an app that communicates with a sensor and, when Clock2 triggers, if the temperature or humidity minimum or maximum thresholds are exceeded, the app sounds a spoken text alarm.
I have three blocks below. The first two work. If I just check temperature, the app reports when the min and max thresholds for temperature have been exceeded. If I just test for humidity, the same holds true and I can test for when the min and max set humidity is exceeded.
When I try to use both if/then subsets together, things get whacky and not all conditions are reported. Would someone with more skill than I please advise me as to my error(s)? I believe the error lies in my lack of knowledge about how to test both conditions, and not outside this group of blocks.
Here is an experiment for you to try, using the Do It facility.
I just did it on my phone, and I want to see if you can appreciate the results of the experiment.
Locate a block of code that invokes speech for two different messages, and connect your phone in the Companion so that when you apply Do It to those speech blocks, your phone speaks the message.
In quick succession, apply Do It to the first message, then to the second message while the first message is still being spoken.
Have the second message rudely interrupt the first.
Now think back to the last time we discussed this problem.
I think you mean search my entries for a possibly relevant message from you, as my memory is spotty and, when I am attempting different solutions, I tend to dismiss that which previously didn't work.
If @Taifun is not pulling my leg, his is a simpler solution that requires no memory recall on my part.
if ( (temperature > tempMax) or (temperature < tempMin) or (humidity > humidityMax) or (humidity < humidityMin) )
then
call Speaker1.Speak ("Temperature or humidity threshold exceeded!")
end
Or
When Clock2.Timer
do
if ( (temperature > tempMax) or (temperature < tempMin) )
then
call Speaker1.Speak ("Temperature threshold exceeded!")
if ( (humidity > humidityMax) or (humidity < humidityMin) )
then
call Speaker1.Speak ("Humidity threshold exceeded!")
Actually the third one should work as you expected. Doesn't? Or use one lable in all four situation to know whether the four circumstances are triggering properly or not. You may use lable text as 1,2,3,4 for all the four. So depending upon the text appear you will come to know which instances was triggered and can design further logics. Also make sure both true will not trigger at a time to avoid confusion in the speech
Here is a sample you can play with for the multiple Clock approach in
For slowly changing values like temperature and humidity, multiple very slow clocks with different intervals can deliver the error messages most of the time.