2014년 12월 27일 토요일

If Statement Not working Properly?

Hi, Im new here, and im working on an app using orientation and GPS, but i found a problem and i dont know how to solve it,
i've tried lot of stuff, but it looks its not working...

So, the main idea is to send a Text when the -Azimuth- is out of range, but when it happens, it goes like crazy, i've tried to use a flag to stop it, but didn't work, so, after trial and error, i didnt get it run ok.

I guess it should be something really easy, but cant figure out what it is.

Any idea?




If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...




Thanks for the advice, here it is.



the orientation changed event fires permanently, probably too often for your purposes
you could move all your blocks into a Clock.Timer event instead and set the timer interval to 1000ms
also use Do it to debug your blocks



You could also keep a global instant variable, "LastAlarmSentInstant".

Start it off as Now() during program initialization.

When an alarm condition is sensed,
compare the Clock1.Duration between NOW() and LastAlarmSentInstant
against some required minumum interval between alarms, say 5 seconds.

If we haven't reached that duration yet, skip the alert logic.

If enough time has passed, proceed to alert by setting LastAlarmSentInstant to Now()
and issuing an SMS.



I added the clock and it just makes the same but slower I also made some adjustments, but still not working as desired, I'll keep trying



If you are using text to speech, you need to insure you are
not overlapping multiple speech outputs.
There's a brown speech block to hold blocks for
when the last speech ended.  That's a good place
to re-enable the clock, which should be disabled
while it's talking.



So, i found the problem, as i thought... it was a minior and noob problem, in the "else if" statement, you can see, the comparsion is set to "or", changing it to "and" solves the problem (o_o")

Thanks for your support =D


댓글 없음:

댓글 쓰기