html5 wait command (workaround)

Bringing your stacks to the web

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

html5 wait command (workaround)

Post by seaniepie » Mon Jul 15, 2019 7:04 pm

A simple bit of code to produce an alternative for 'wait' that works for html5 deployment:

Code: Select all

on waitFor pMS
   put the millisec into tMS
   put the millisec - tMS into tMSDiff 
   repeat until tMSDiff >= pMS
      put the millisec - tMS into tMSDiff
   end repeat
end waitFor
Obviously, this causes the stack to hang and can't process any messages. One handy thing though is that buttons and other UI items also become unresponsive, so it prevents user interaction during this time (without affecting the rest of the browser).

I'm working on a way to do it with messages. I'll post here when I'm done.

Pi

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: html5 wait command (workaround)

Post by [-hh] » Mon Jul 15, 2019 8:28 pm

You could simply use "send in <time>". It's better than wait, not only a workaround.
shiftLock happens

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: html5 wait command (workaround)

Post by seaniepie » Mon Jul 15, 2019 8:49 pm

So, amazingly, send "{command}" to me in 2 sec works, even though wait can't. Therefore, wait with messages is easy(ish). You just split up your code:

Code: Select all

on myCommand_1
   -- Do some stuff...
   send "myCommand_2 tMyParametersToPassInAnArray" to me in 1 second 
   -- ^ Is the same as 'wait 1 sec with messages' ^
end myCommand_1

on myCommand_2 pParameterArrayPassedFromPreviousHandler
   -- Break out the parameters if you don't want to carry on using them in the array...
   -- Carry on and do more stuff...
end myCommand_2
Simple!

Pi

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: html5 wait command (workaround)

Post by seaniepie » Mon Jul 15, 2019 9:08 pm

[-hh] wrote:
Mon Jul 15, 2019 8:28 pm
You could simply use "send in <time>". It's better than wait, not only a workaround.
Sorry, Hermann, only just noticed this post. I (wrongly) assumed that because wait didn't work (heaven knows why - JS can do a wait functions) that 'send in' wouldn't either.

My SQL library is just about done.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: html5 wait command (workaround)

Post by sphere » Tue Jul 16, 2019 10:26 am

That would be awesome and give huge advantages if we can use Mysql with html5 8)

Post Reply

Return to “HTML5”