PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 22 → [WM]Loop and a timer
[WM]Loop and a timer
Débuté par Jim, 07 juin 2018 18:54 - 2 réponses
Posté le 07 juin 2018 - 18:54
I have an app that sends an sms to get status from a device.
It works great when the text comes back from the device.
But, if the device is off or doesn't respond, I would like it to time out.
I cannot find a way to do that.
The LOOP seems to lock down and nothing else operates while the LOOP is in a loop.
I have tried simple automated procedures, using the clock, etc.
Nothing has worked. Is there a way to check for a new incoming message without a LOOP?

nNummmessages is int = SMSNbMessage(smsMemory)
rslt is boolean = SMSSend()

IF rslt = True THEN


LOOP
x = SMSNbMessage(smsMemory)

IF x <> nNummmessages THEN BREAK


END

END

Thanks

Jim
Posté le 07 juin 2018 - 22:30
Hi Jim,

one way of doing that is to add a test on elapsed time inside your loop
and do a break if more than x seconds has elapsed

Another way is to use a timer instead of a loop to check every x 1/100
of a second if a new sms arrived and to count the number of times you
enter the timer. If N times is reached to stop the timer

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on http://www.fabriceharari.com



On 6/7/2018 10:54 AM, Jim wrote:
I have an app that sends an sms to get status from a device.
It works great when the text comes back from the device.
But, if the device is off or doesn't respond, I would like it to time out.
I cannot find a way to do that. The LOOP seems to lock down and nothing
else operates while the LOOP is in a loop.
I have tried simple automated procedures, using the clock, etc. Nothing
has worked.  Is there a way to check for a new incoming message without
a LOOP?

nNummmessages is int = SMSNbMessage(smsMemory)
rslt is boolean = SMSSend()

IF rslt = True THEN


                    LOOP
                        x = SMSNbMessage(smsMemory)

                        IF x <> nNummmessages THEN BREAK


                    END

    END

Thanks

Jim
Posté le 08 juin 2018 - 18:38
Fabrice,

Thanks, I tried option 2 and it is working.
I finally got my mind wrapped around these timers (automated procedures).
I had to have all my code in there, not back in the main thread.

Thanks again!

Jim