PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → [WM]Loop and a timer
[WM]Loop and a timer
Iniciado por jw, jun., 07 2018 6:54 PM - 2 respostas
Publicado em junho, 07 2018 - 6:54 PM
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
Publicado em junho, 07 2018 - 10:30 PM
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
Publicado em junho, 08 2018 - 6:38 PM
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