Handler not recognising images

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
kjones
Posts: 6
Joined: Mon Feb 25, 2013 6:21 am

Handler not recognising images

Post by kjones » Wed Feb 27, 2013 3:01 am

I have created a handler called “timeout” – which I send to my card after 6 seconds (it is a reaction time experiment and I want to stop participants from responding and tell them they are too slow if they take longer than 6 seconds which is what I am aiming to do with this handler)

Basically the experiment just involves some pictures popping up and then participants need to respond either by pressing the “z” or “/” keys.

My problem is that the “timeout” handler (which is on card X) won’t recognize images (in a fld on the same card) even though earlier handlers on the same card have recognised and ‘dealt’ with the image
i.e. on opencard an image is shown (LiveCode reads the code here fine)

I then want that image to be hidden on “timeout” - it begins “timeout” but when it reaches the hide command it tells me “no such object exists”…..despite it putting it up on the screen seconds before during “opencard”

I am very new to LiveCode and very confused…


My (...long) script is below in case 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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Handler not recognising images

Post by Klaus » Wed Feb 27, 2013 10:15 am

Hi kjones,

you need to use parenthesis when concatenating names of objects like this:
...
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")
## etc.
...
That should do the trick.


Best

Klaus

Post Reply