Hello! I have been using LiveCode for about 6 months and it has been going really well. I have programmed several types of programs, but I recently ran into a problem (that I eventually solved) but the solution seems to be a less than efficient way to do it.
I need to run two tasks in an experiment simultaneously. In one task subjects are presented a list of words, one word at a time every 3 seconds. At the exact same time subjects are hearing single digits spoken every 1 second through the "say" command for applescript (they have to press a key if they hear 3 odd digits in a row).
Here is a simplified version of the method that I did that currently "works" but may not be the best method:
on task
send sayone to me in 1000 milliseconds
send saytwo to me in 2000 milliseconds
send "put factory into me" to me in 3000 milliseconds
send saythree to me in 3001 milliseconds
send sayfour to me in 4000 milliseconds
send sayfive to me in 5000 milliseconds
send "put tower into me" to me in 6000 milliseconds
end task
on sayone
do item 1 of line 1 of fld "Say Digits" as applescript
end sayone
on saytwo
do item 1 of line 2 of fld "Say Digits" as applescript
end saytwo
....
Note that here "me" = a fld, and that I am calling the "do" commands from another field with a list of the applescript commands
Any ideas on how to improve this method please let me know, otherwise it's going to be a while before I get this program done haha!
Thanks!
Josh
send command with two tasks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: send command with two tasks
Josh-
What you've got will work, of course, but I think I'd approach it a little differently.
I'd start with two lists, one for the words to be spoken and one for the visible lists...
What you've got will work, of course, but I think I'd approach it a little differently.
I'd start with two lists, one for the words to be spoken and one for the visible lists...
Code: Select all
local sCurrentDigit
local sCurrentWord
on task
-- fill fields here if they're not already filled
put 1 into sCurrentDigit
put 1 into sCurrentWord
sayDigit
showWord
end task
on sayDigit
if line sCurrentDigit of field "Say Digits" is empty then
exit sayDigit
end if
do item p1 of line sCurrentDigit of field "Say Digits" as applescript
add 1 to sCurrentDigit
send "sayDigit" to me in 1 second
end sayDigit
on showWord
if line sCurrentWord of field "fldWords" is empty then
exit showWord
end if
put line sCurrentWord of field "fldWords" into me
add 1 to sCurrentWord
send "showWord" to me in 3 seconds
end showWord
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: send command with two tasks
Great! After a couple of minor changes to your suggested code it worked perfectly.
Thanks so much!
Thanks so much!
Re: send command with two tasks
Cool.
I think this sort of situation (repeating asynchronous events) is where the "send in time" statement really comes into its own.

I think this sort of situation (repeating asynchronous events) is where the "send in time" statement really comes into its own.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev