wait without locking up the rest of interface

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

wait without locking up the rest of interface

Post by Da_Elf » Tue Aug 26, 2014 11:14 pm

Its a tough one to search the forum for and i didnt find anything here on googled. Is it possible to have a script running in the background that might use some wait commands but dont have it affect anything else from working?

for example

Code: Select all

on mouseUp
  codeA
  codeB
  codeC
end mouseUp
on codeA
  wait 5 seconds
  set the text of field "A" to "A"
end codeA
on codeB
  wait 4 seconds
  set the text of field "B" to "B"
end codeB
on codeC
  wait 3 seconds
  set the text of field "C" to "C"
end codeC
with this code A will fill in after 5 seconds, then B 4 seconds after that, then C will be 3 seconds after that totaling 12 seconds

what if on mouseUp i wanted all those to run but C will go in 3 seconds a seconds after that B and A a second after that all in 5 seconds. I know i can use 3, 1 and 1 for my waits and structure it in order but there are cases where i want all 3 to run at the same time and not have them lock up the interface

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: wait without locking up the rest of interface

Post by Simon » Wed Aug 27, 2014 12:08 am

I think "send" is your friend here;

Code: Select all

on mouseUp
  send codeA to me in 5 seconds
  send codeB to me in 4 seconds
  send codeC to me in 3 seconds
end mouseUp
get rid of your "wait"'s.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: wait without locking up the rest of interface

Post by Da_Elf » Wed Aug 27, 2014 1:16 am

what im saying is ive got a bunch of scripts that have waits inside of them. my example code was simplistic. im talking about something thats got about 20 lines of code in it and somewhere in there is a wait on some of the scripts. but i dont want that wait to affect anything else. id like to be able to still do stuff while that particular one is waiting to do what it needs to do

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: wait without locking up the rest of interface

Post by Da_Elf » Wed Aug 27, 2014 2:15 am

tried it your way and livecode didnt like the send line

Code: Select all

stopVideos baseLayer,LayerGraphic,LayerAudio,LayerFlash
send clearVideo LayerAlpha, baseLayer, LayerGraphic, LayerAudio to me in 700 milliseconds

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: wait without locking up the rest of interface

Post by Simon » Wed Aug 27, 2014 4:10 am

my example code was simplistic.
And thus you got a simplistic answer as I only know what you tell me.
tried it your way and livecode didnt like the send line
Nope, only 1 command per send like in the example I showed.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: wait without locking up the rest of interface

Post by dunbarx » Wed Aug 27, 2014 4:58 am

Hi.

"Send' can, er, send parameters as well as a command. In a button script:

Code: Select all

on mouseUp
   send "putArg" && random(99) && random(99)  && "XYZ" to me in 5
end mouseUp

on putArg var
   put var
end putArg
You get pairs of random numbers and the text as well. All parameters come across as a batch.

Or you can separate in the usual way:

Code: Select all

on mouseUp
   send "putArg" && random(99) & "," & any char of "ABCD" to me in 5
end mouseUp

on putArg var,var2
   put var2 --or the first one or both
end putArg
Craig

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: wait without locking up the rest of interface

Post by Da_Elf » Wed Aug 27, 2014 3:34 pm

those are not commands. its 1 command "clearvideo" the rest are the variables im passing into the command

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: wait without locking up the rest of interface

Post by FourthWorld » Wed Aug 27, 2014 5:04 pm

With "send", what's being sent must be a single string, even if it includes variable names as arguments. These are evaluated during the send, much as they would be evaluated when called inline.

This should work:

Code: Select all

send "clearVideo LayerAlpha, baseLayer, LayerGraphic, LayerAudio" to me in 700 milliseconds
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: wait without locking up the rest of interface

Post by Da_Elf » Wed Aug 27, 2014 5:35 pm

aaaahhhh. i have to quote whats being sent. gotcha

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: wait without locking up the rest of interface

Post by Da_Elf » Wed Aug 27, 2014 5:52 pm

whoohoo. i'm getting married to send. i love send

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: wait without locking up the rest of interface

Post by Simon » Wed Aug 27, 2014 6:09 pm

whoohoo. i'm getting married to send. i love send
You're gonna have to wait in line...
But "send" knows I'm dating "put URL" and "repeat for each" on the side.
I've got my eye on "filter" but I think she's too smart for me. :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply