Page 1 of 1

wait without locking up the rest of interface

Posted: Tue Aug 26, 2014 11:14 pm
by Da_Elf
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 12:08 am
by Simon
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 1:16 am
by Da_Elf
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 2:15 am
by Da_Elf
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 4:10 am
by Simon
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 4:58 am
by dunbarx
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 3:34 pm
by Da_Elf
those are not commands. its 1 command "clearvideo" the rest are the variables im passing into the command

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 5:04 pm
by FourthWorld
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

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 5:35 pm
by Da_Elf
aaaahhhh. i have to quote whats being sent. gotcha

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 5:52 pm
by Da_Elf
whoohoo. i'm getting married to send. i love send

Re: wait without locking up the rest of interface

Posted: Wed Aug 27, 2014 6:09 pm
by Simon
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