Page 1 of 2

how to add a time-out during trials

Posted: Mon Feb 25, 2013 6:36 am
by kjones
Hi All

I am very new to LiveCode and have hit a wall.

I've been asked to alter a program by adding a time-out conditon whereby if a response is not made within 10 seconds the current trial is aborted and the new one begins.

In this case a trial is a picture popping up and particpants must then hit either "z" or "/" on the keyboard, pressing either of these buttons then trigers the next trial to begin by hiding the current picture and displaying a new one.

I tried using a countdown and stipulating that if the fld "countdown" = 0 then hide image etc BUT during the countdown it won't allow a response to be made.

Any help on how to allow a response but then stop one being made after 10 seconds would be great!

thanks

Kelly

Re: how to add a time-out during trials

Posted: Mon Feb 25, 2013 7:10 am
by Simon
Oh this is funny....
Are you part of a psychiatry or medical team?
Trial here means a software trial, as in 30 days free use. :)

OK aside from that:
I'm going to make a guess that you have timer that has "wait 1 second" or something like that.
Change it to:
wait 1 second with messages

Wait is a blocking command that will ignore all other commands until it's done (as in, stand there don't move a muscle!), the "with messages" allows other messages to pass.
Don't forget you will also have to reset your timer back to 10 after the z or /. Using a local for your count makes it easy:
on rawKeyDown tKey
if tKey = z then
--new image
-- put 10 into tCount
pass rawKeyDown
end--

Simon

Re: how to add a time-out during trials

Posted: Mon Feb 25, 2013 11:01 pm
by Simon
After sleeping on this I think I may have left too much out:

Code: Select all

on rawKeyDown tKey
   if (numToChar(tKey) = "z") or (numToChar(tKey) = "/") then
--get new image
      put 10 into tCount
      exit to top --this will exit all repeat loops and wait commands
   else
      pass rawKeyDown
   end if
end rawKeyDown
There, that is better.
But I think that I am still getting it wrong.
...within 10 seconds the current trial is aborted and the new one begins.
... "z" or "/" on the keyboard, pressing either of these buttons then trigers the next trial to begin
These two lines read to me as the same.
Could you elaborate a bit more please?

Simon

Re: how to add a time-out during trials

Posted: Mon Feb 25, 2013 11:59 pm
by dunbarx
Hi.

Put this in a button.

Code: Select all

on mouseup
  startCountDown the ticks
end mouseup

on startCountDown tStart
   if the ticks - tStart < 600 then
      if the KeysDown = 122 or the keysDown = 47 then
         answer "Congrats"
         exit startCountDown
      else
         send "startCountDown" && tStart to me in 1
      end if
   else
      answer "No Bueno"
   end if
end startCountDown
Verbose, but that is so you can put your own stuff in the right places.

Craig Newman

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 12:42 am
by kjones
Thanks for your suggestions guys

Simon - it is a psychology team :) I realised when I tried searching for help that I may have problems with the word “trial” but it's been engrained into me!
- I tried using the "wait 10 seconds with messages" however it still won't allow a key response to be made in this time. This may be due to where I put it in my code, however I placed it after enabling keydown and it still won’t let me press the “z” or “/” before the 10 seconds is up
within 10 seconds the current trial is aborted and the new one begins.
... "z" or "/" on the keyboard, pressing either of these buttons then trigers the next trial to begin”
- Essentially it is the same thing. People see the picture and have to respond to it (1 trial) and then they get a new picture. It is a reaction time experiment so if people take longer than 10 seconds they are taking far too long making a decision about the picture so we want to, remove that picture, record that this response is N/A, tell them they are “too slow” and move onto the next picture.

- I’m really just guessing with some of this. For example I know that you can code
if fld “age” is empty….
or if hilitedbutton of grp “gender” is none….
But I don’t know what the equivalent for key pressing is. I have guessed that it is “none”…

Craig - I’m not sure if I can use this code because both of the key presses need to record different things? i.e. noting which key was pressed (apologies for not including that in the earlier post).



Here is my code for the key pressing if it helps explain (it is very long….and apologies if it’s ugly programming!!)

Code: Select all

on keydown thekey
   set the itemdelimiter to tab
   if buttonresponding = "enable" then
      wait 10 seconds with messages
      if thekey = none then
         show fld "tooslow"
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "tooslow" & tab & "NA" & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 2 seconds
         add 1 to trial 
           switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                        switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
      end if
      if thekey = "z" then
         put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "Yes" & tab & 1 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                        switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
      end if
      
      if thekey = "/" then
         put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "No" & tab & 0 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                     switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
      end if
   end if
   put flushevents ("keydown") into trash
end keydown

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 1:45 am
by Simon
Ok here it is:

Code: Select all

on keydown thekey
   set the itemdelimiter to tab
   if buttonresponding = "enable" then
      repeat  1000
         if  thekey = 122 or thekey = 47 then   -- 122 = z and 47 = /
            exit repeat
         else
            wait 1 millisecond with messages
         end if
      end repeat
      --wait 10 seconds with messages
      if thekey = none then
In no way do I suggest that this is the "correct" way to solve the problem.
Just the fastest fix to your current code :)

Simon

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 1:47 am
by magice
rewrite it so that the first line is
send tooSlow to me in 10 seconds

then put in your switch without the "too slow" case

then
on tooSlow
do what you want for too slow
end too slow

You need to find a way to eliminate all of the wait commands and replace them with send commands. Otherwise even if you get it to work, it will not be consistent. When you use wait, the processor is tied up until the wait is over. The processor needs to be able to execute the commands at its own speed. Think of it like someone telling you to move a heavy object, but after you pick it up and move it you have to wait for them to clean off a space for you to set it down. That is what the wait command does to your processor. Instead clean off the spot before you move the object. :D

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 1:54 am
by Simon
Forget my above posting
1 more try:

Code: Select all

on keydown thekey
   set the itemdelimiter to tab
   if buttonresponding = "enable" then
      repeat  10000
         if  (thekey = "z") or (thekey = "/") then 
            exit repeat
         else
            wait 1 millisecond with messages
         end if
      end repeat
      --wait 10 seconds with messages
      if thekey = none then
In no way do I suggest that this is the "correct" way to solve the problem.
Just the fastest fix to your current code

Simon EDIT: I changed the code a little
EDIT2: still something wrong as "if thekey = none then" will never trigger because it's in a keyDown--RATS. Back to the drawing board.

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 2:21 am
by dunbarx
I think mine is bigger.

In a button:

Code: Select all

on mouseup
  startCountDown the ticks
end mouseup

on startCountDown tStart
      if the ticks - tStart < 600 then
           switch the keysDown
         case 122
            answer "Z"
            exit startCountDown
         case 47
            answer "/"
            exit startCountDown
      end switch
       send "startCountDown" && tStart to me in  1
   else
        answer "No Bueno"
      end if
end startCountDown
You can now put different stuff into the "z" or the "/" choice.

Craig Newman

Re: how to add a time-out during trials

Posted: Tue Feb 26, 2013 2:32 am
by Simon
:D
I'm off to join Scott Rossi at Google :lol:

Simon

Re: how to add a time-out during trials

Posted: Wed Feb 27, 2013 12:50 am
by kjones
thanks for the help again guys - still having issues though

there is no button I can code on to as its a continous run through "trials", they do not press any buttons between trials and the experimenter will not be there to press any anything for them. So all my script is on the card script.

I think I have found a way around this - by the simple process of making a new handler called "timeout", i.e. send "timeout" to this card in 10 seconds

BUT now it is freaking out by not recognising my images: when it gets into this handler it tells me "no such object" BUT it has already recognised the object earlier and popped it up on screen in the "opencard" handler

This is really confusing me as it reads it early on but then tells me that its an error ?!

below is the code for my handler "timeout", it gives me the error when it reaches "hide image item 1 of line trial of fld "doglist""

Code: Select all

on timeout
   put "disable" into buttonresponding
     put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide image item 1 of line trial of fld "doglist"
          hide fld "question"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "timeout" & tab & "NA" & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         show fld "tooslow"
         wait 2 seconds
         hide fld "tooslow"
         wait 30 ticks
         add 1 to trial 
         put flushevents ("keydown") into trash
end timeout

before this code I have my "keydown" handler/command and I don't know if thats what could be causing the issue.....?

Code: Select all

on opencard
   set the itemdelimiter to tab
   show fld "question"
   wait 30 ticks
   show fld "buttonreminder"
   show image item 1 of line trial of fld "doglist"
   put "enable" into buttonresponding
   put the ticks into startticks
   put the millisecs into startmilliseconds
   send "timeout" to this card in 10 seconds
end opencard

on keydown thekey
   set the itemdelimiter to tab
   if buttonresponding = "enable" then
      if thekey = "z" then
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "Yes" & tab & 1 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               break
         end switch
      end if
      
      if thekey = "/" then
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "No" & tab & 0 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
                break
         end switch
      end if
   end if
   put flushevents ("keydown") into trash
end keydown

Re: how to add a time-out during trials

Posted: Wed Feb 27, 2013 2:54 am
by Simon
Hi Kelly,
There are too many unknowns here for me to debug.
"hide image item 1 of line trial of fld "doglist""
The simple answer is there is no image "item 1 of line trial of fld "doglist"" but I expect you have already tested for this.
For me, at this point, you would have to post your stack with a description of how to replicate the error.

Other's here may be able to see what is the issue with the above posted scripts.

Simon

Re: how to add a time-out during trials

Posted: Wed Feb 27, 2013 4:25 am
by kjones
HI Simon

thanks for the response. It won't seem to allow me to post my stack on here.

There is definitely “image item 1 of line trial of fld “doglist””, it even displays it earlier in the script under the opencard handler. I’m guessing that it’s continuing on from here (opencard) and reading all the keydown stuff and this is perhaps sending it mixed messages about what to do…or it thinks its already hidden the image so won’t hide it again (except I don’t think this would lead to the ‘no such object error message’..?)

script for the card is below if it helps

Code: Select all

global trial, condition, buttonresponding, startticks, startmilliseconds, blocknow
on preopencard
   set the itemdelimiter to tab
   put 1 into trial
   hide fld "question"
   hide fld "buttonreminder"
   hide fld "wait"
   hide fld "countdown"
   hide btn "start"
   hide fld "continue"
   hide fld "tooslow"
   put scramble (fld "doglist") into fld "doglist"
   repeat with a = 1 to 80
      set the loc of image item 1 of line a of fld "doglist" to 600,450
      hide image item 1 of line a of fld "doglist" 
   end repeat
   switch
      case condition = "induction"
         put "Does this animal have beta cells?" into fld "question"
         break
      case condition = "recognition"
         put "Did you see this animal in the STUDY phase?" into fld "question"
         break
   end switch   
   put linefeed & linefeed & linefeed & "Block"& Blocknow & linefeed & "Trial" & tab & "ImageName" & tab & "ImageNumber" & tab & "Old1=Yes;0=No" & tab & "ImageType1=OldLarge;2=Medium;3=Small;4=NewLarge" & tab & "Response" & tab & "ResponseCoded" & tab & "ReactionTime(Ticks)" & tab & "ReactionTime(Scalculatedfromticks)" & tab & "ReactionTime(MScalculatedfromticks)" & tab & "ReactionTime(MScalculatedfromMS)" after fld "data" of card "demo"
end preopencard

on opencard
   set the itemdelimiter to tab
   show fld "question"
   wait 30 ticks
   show fld "buttonreminder"
   show image item 1 of line trial of fld "doglist"
   put "enable" into buttonresponding
   put the ticks into startticks
   put the millisecs into startmilliseconds
   send "timeout" to this card in 6 seconds
end opencard

on keydown thekey
   set the itemdelimiter to tab
   if buttonresponding = "enable" then
      if thekey = "z" then
         put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "Yes" & tab & 1 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                        switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
      end if
      
      if thekey = "/" then
         put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide fld "question"
         hide image item 1 of line trial of fld "doglist"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "No" & tab & 0 & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                     switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
      end if
   end if
   put flushevents ("keydown") into trash
end keydown


on timeout
   put "disable" into buttonresponding
     put the milliseconds into endmilliseconds
         put the ticks into endticks
         put endticks - startticks into ellapsedticks
         put ellapsedticks/60 into ellapsedseconds
         put ellapsedseconds*1000 into ellapsedmillisecondsaccordingtoticks
         put endmilliseconds - startmilliseconds into ellapsedmilliseconds
         hide image item 1 of line trial of fld "doglist"
          hide fld "question"
         hide fld "buttonreminder"
         put linefeed & trial & tab & line trial of fld "doglist" & tab & "timeout" & tab & "NA" & tab & ellapsedticks & tab & ellapsedseconds & tab & ellapsedmillisecondsaccordingtoticks & tab & ellapsedmilliseconds after fld "data" of card "demo"
         show fld "tooslow"
         wait 2 seconds
         hide fld "tooslow"
         wait 30 ticks
         add 1 to trial 
         switch
            case trial <81
               show fld "question"
               wait 30 ticks
               show fld "buttonreminder"
               show image item 1 of line trial of fld "doglist"
               put the milliseconds into startmilliseconds
               put the ticks into startticks
               break
            case trial >80
               add 1 to blocknow
               switch
                  case blocknow > 4
                     go to card "end"
                     break
                  case blocknow < 5
                        switch
                        case condition = "induction"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals that have beta cells." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown have beta cells." into fld "continueinstructions"
                           break
                        case condition = "recognition"
                           put "We will now have another go." & linefeed & "In the study phase you will again see some animals and be asked to remember them." & linefeed & "You will then be shown some more pictures and asked to decide if the animals shown were shown to you in the study phase." into fld "continueinstructions"
                           break
                     end switch
                     show fld "continueinstructions"
                     show fld "wait"
                     show fld "countdown"
                     repeat with countdown = 60 down to 1
                        put countdown into fld "countdown"
                        wait 1 seconds 
                     end repeat
                     show fld "continue"
                     show btn "Start"
                     break
               end switch
               break
         end switch
         put flushevents ("keydown") into trash
end timeout

Re: how to add a time-out during trials

Posted: Wed Feb 27, 2013 5:27 am
by Simon
What is in fld "doglist"?
I have a feeling you are not using the image object correctly.

WOW this is guessing wildly:
You only have a single image object on the card
It has a name and ID. This is NOT what it contains.

Lets say the image object is called myPic

Code: Select all

set the filename of image "myPic" to specialFolderPath("documents") & "/bigdog.jpg"
That is how you can change what the image "myPic" shows.
Field "dogList" should have a bunch of picture names or complete url to the images if you haven't set the default folder.

Now to hide and show

Code: Select all

hide image "myPic"
set the vis of image "myPic" to true --hide/show vis true false are the same thing
Note that it is not hide image bigdog.jpg
This is so much guesswork of what you have it hurts. :?

Simon

Re: how to add a time-out during trials

Posted: Wed Feb 27, 2013 5:58 am
by kjones
Thanks for your patience and persistence Simon!

The fld contains information on 80 images, i.e. its jpg 'name' and other coded info which gets recorded. For me in the past (and by past I mean the whole 2 weeks I've been working with this program..) image item 1 would refer to the first piece of info in the fld, so the jpg name. I haven't had a problem with it before, but this is the first time I'm using it inside a handler I have created myself.

The reason I have the images listed in a fld on the card and not being read from a folder is that the images have to appear in a random order for each person who sits the experiment, so earlier in the script the order of the contents of the fld gets scrambled.


The set up of fld 'doglist' is as follows (but with 80 lines):

L11.jpg 71 0 4
L13.jpg 73 0 4
M12.jpg 32 0 2
S06.jpg 46 0 3
S11.jpg 51 0 3
SL10.jpg 10 1 1
SL20.jpg 20 1 1
M17.jpg 37 0 2
L10.jpg 70 0 4

I don't know if this helps clarify things much, there's still so much I don't know about this program it's hard to know what info to give