Strange sporadic slider behaviour

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

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 6:46 pm

Thank you for the incredibly thorough reply. You were right about what my study entails, very impressive. Rather like palm reading, except actually true.

I have taken your code recommendations and attempted to apply them, however, it appears that the image field "Photo" is not changing the image during the cycleup / cycle down (the thumbposition does move however). Further the image does not load in when scrolling the "Slider2".

The images themselves are located in a folder called "Figures", and are sequentially named, 1-0.bmp, 1-1.bmp.... 1-50.bmp.... 144-0.bmp, 144-1.bmp, 144-100.bmp .

I am not sure why this problem is occurring, I tried making "ImageNum" a global.

Other than the not loading of the images, the program does what it is supposed to from what I can see (Timeouts are appropriate, the pressing of the mousedown to initiate Validresponse etc)

For now I am running participants without the timeouts being called and it is running stable enough.

I will tinker some more,

Thank you for the time and effort,

I appreciate it,

-Brandon

I will now post the code I am tinkering with

Code: Select all

global stimlist, photopath, trialnum, imagenameexp

on scrollbardrag 
  put the thumbpos of scrollbar "slider2" into x
   set the itemdelimiter to tab
  set the filename of image "photo" to photopath&imagenameexp&"-"&x&".bmp"
end scrollbardrag

Code: Select all

global thepath, photopath, datapath, imagelist, Data, voicelist, response, soundpath, listened, responseTime, fName, stimlist, trialnum, responseVal, TimeOutID, ImagenameExp, StartNum, Endnum, t1, stimlist, imagenum
ValidResponse

local maxTrial, maxTrial2 

on preopenCard 
   hide image "Photo" 
   hide player "Voices" 
   hide scrollbar "Slider" 
   hide scrollbar "Slider2" 
   hide button "Next"
   hide button "Next2" 
   hide button "Replay" 
   hide image "fixation" 
   hide fld "EndofTime" 
   hide fld "EndofExperiment" 
   hide fld "Break" 
   hide fld "Break2" 
   hide button "Resume" 
end preopencard 


on opencard 
   put 72 into maxTrial 
   put 144 into maxTrial2 
   put 1 into trialnum 
    
   beginExperiment 
    
end openCard 

on beginExperiment 
   
   get flushevents("all")
   put 0 into response 
   put 0 into listened 
   if trialnum <= maxTrial then 
      
      show image "fixation" 
      wait 1 second 
      hide image "fixation" 
      
      set the itemdelimiter to tab 
      -- this setting remains in force within this handler, but only in this handler (locally) 
      set the filename of player "Voices" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices2" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices3" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices4" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices5" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      
      
      set the filename of image "Photo" to empty 
      
      set the lockscreen to true 
      show image "photo" 
      show scrollbar "Slider" 
      disable button "Next" 
      disable button "Next2"
      disable button "Replay" 
      set the lockscreen to false 
      
      put random (2) into donkey 
      /* It is more efficient to extract item 6 into a variable, for use in the repeats and scrolls, as well as making the script easier to follow. It is used by CycleImages and scrolllbardrag. */ 
      put item 6 of line trialNum of stimList into imageName 
      if donkey = 1 then 
         TestPath1 
      end if 
      
      if donkey = 2 then 
         TestPath2 
      end if 
      
      put donkey into item 20 of line trialnum of stimlist 
      
      set the lockscreen to true 
      show button "Next" 
      show button "Replay" 
      
      hide scrollbar "slider" 
      set the thumbpos of scrollbar "slider2" to 25 
      enable scrollbar "slider2" 
      show scrollbar "slider2" 
      enable button "Next" 
      enable button "Replay" 
      set the lockscreen to false 
      
      put the milliseconds into t1 
      send "timeout" to me in 15 seconds 
      put the result into timeOutID 
   else 
      hide scrollbar "Slider" 
      hide scrollbar "Slider2" 
      hide button "Next" 
      hide button "Replay" 
      show field "Break" 
      wait 60 seconds 
      hide field "Break" 
      show field "Break2" 
      show button "Resume" 
   end if 
end beginExperiment 

on TestPath1 
   global startNum, endNum 
   play stop 
   start player "Voices2" 
   disable scrollbar "Slider2" 
   disable scrollbar "Slider" 
   -- display image 25 up to 50 
   put 25 into startNum 
   put 50 into endNum 
   CycleImagesUp 
   -- display image 49 down to 25 
   put 49 into startNum 
   put 25 into endNum 
   CycleImagesDown 
    
   play stop 
   start player "Voices3" 
   -- display from image 24 down to 0 
   put 24 into startNum 
   put 0 into endNum 
   CycleImagesDown 
   -- display from image 1 up to 25 
   put 1 into startNum 
   put 25 into endNum 
   CycleImagesUp 
    
   play stop 
   start player "Voices4" 
end TestPath1 

on TestPath2 
   global startNum, endNum 
   play stop 
   start player "Voices2" 
   disable scrollbar "Slider2" 
   -- display from image 25 down to 0 
   put 25 into startNum 
   put 0 into endNum 
   CycleImagesDown 
   -- display from image 1 up to 25 
   put 1 into startNum 
   put 25 into endNum 
   CycleImagesUp 
    
   play stop 
   start player "Voices3" 
   --display from image 26 up to 50 
   put 26 into startNum 
   put 50 into endNum 
   CycleImagesUp 
   -- display from image 49 down to 25 
   put 49 into startNum 
   put 25 into endNum 
   CycleImagesDown 
    
   play stop 
   start player "Voices4" 
end TestPath2 

on CycleImagesUp 
   global startNum, endNum, photoPath, trialNum, stimList 
   repeat with imageNum = startNum to endNum 
      set the fileName of image "Photo" to photopath&imageNameExp&"-"&imageNum&".bmp" 
      set the thumbPosition of scrollbar "Slider" to imageNum 
      wait 8 milliseconds with messages 
      /* "with messages" is added here, as Bernd suggests. */ 
   end repeat 
end CycleImagesUp 

on CycleImagesDown 
   global startNum, endNum, photoPath, trialNum, stimList 
   repeat with imageNum = startNum down to endNum 
      set the fileName of image "Photo" to photopath&imageNameExp&"-"&imageNum&".bmp" 
      set the thumbPosition of scrollbar "Slider" to imageNum 
      wait 8 milliseconds with messages 
   end repeat 
end CycleImagesDown 

on ValidResponse
   global t1, timeOutID, trialnum, stimlist 
   put the milliseconds into t2 
   put t2 - t1 into responseTime 
    
   cancel timeOutID 
    
   set the itemdelimiter to tab 
   saveData responseTime 
   saveChoice 
   set the lockscreen to true 
   hide image "Photo" 
   hide player "voices" 
   hide scrollbar "Slider" 
   hide scrollbar "slider2" 
   hide button "Next" 
   hide button "Replay" 
   hide image "fixation" 
   hide fld "EndofTime" 
   hide fld "EndofExperiment" 
   set the lockscreen to false 
    
   put trialnum into item 1 of line trialnum of stimlist 
    
   add 1 to trialnum 
   send "beginExperiment" to me in 10 milliseconds 
end ValidResponse 

on timeout 
   set the lockscreen to true 
   hide image "Photo" 
   hide player "voices" 
   hide scrollbar "Slider" 
   hide scrollbar "Slider2" 
   hide button "Next" 
   hide button "Replay" 
   set the lockscreen to false 
    
   show field "EndofTime" 
   wait 3 seconds 
   hide field "EndofTime" 
    
   set the itemdelimiter to tab 
   put trialnum into item 1 of line trialnum of stimlist 
   put listened into item 15 of line trialnum of stimlist 
   put "T-O" into item 16 of line trialnum of stimlist 
   put "T-O" into item 17 of line trialnum of stimlist 
   put "T-O" into item 18 of line trialnum of stimlist 
   put "T-O" into item 19 of line trialnum of stimlist 
   add 1 to trialnum 
    
   send "beginExperiment" to me in 10 milliseconds 
end timeout

on beginExperiment2 
   
   get flushevents("all")
   put 0 into response 
   put 0 into listened 
   if trialnum <= maxTrial then 
      
      show image "fixation" 
      wait 1 second 
      hide image "fixation" 
      
      set the itemdelimiter to tab 
      -- this setting remains in force within this handler, but only in this handler (locally) 
      set the filename of player "Voices" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices2" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices3" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices4" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      set the filename of player "Voices5" to soundpath&item 7 of line trialnum of stimlist&".wav" 
      
      
      set the filename of image "Photo" to empty 
      
      set the lockscreen to true 
      show image "photo" 
      show scrollbar "Slider" 
      disable button "Next" 
      disable button "Next2"
      disable button "Replay" 
      set the lockscreen to false 
      
      put random (2) into donkey 
      /* It is more efficient to extract item 6 into a variable, for use in the repeats and scrolls, as well as making the script easier to follow. It is used by CycleImages and scrolllbardrag. */ 
      put item 6 of line trialNum of stimList into imageNameExp 
      if donkey = 1 then 
         TestPath1 
      end if 
      
      if donkey = 2 then 
         TestPath2 
      end if 
      
      put donkey into item 20 of line trialnum of stimlist 
      
      set the lockscreen to true 
      show button "Next2" 
      show button "Replay" 
      
      hide scrollbar "slider" 
      set the thumbpos of scrollbar "slider2" to 25 
      enable scrollbar "slider2" 
      show scrollbar "slider2" 
      enable button "Next2" 
      enable button "Replay" 
      set the lockscreen to false 
      
      put the milliseconds into t1 
      send "timeout2" to me in 15 seconds 
      put the result into timeOutID 
   else 
     
  show field "EndofExperiment"
  wait 5 seconds with messages
  put stimlist into field "Data" of cd "data"
  put stimlist into data
  go to card "data"
  
  put the internet date into y
  put return&"Trialnum"&tab&"Condition"&tab&"Age"&tab&"Language"&tab&"Sex"&tab&"ImageName"&tab&"WordName"&tab&"Con1"&tab&"Vow1"&tab&"Con2"&tab&"Vow2"&tab&"Wordtype"&tab&"1stcontype"&tab&"RealWord?"&tab&"#Replays"&tab&"RT"&tab&"ResponseValue"&tab&"ResponseType"&tab&"Magnitude"&tab&"MvDirection" after y
  put "file:"&DataPath&"D"&the ticks into fName
  put y&return&Data into URL fName
end if
end beginExperiment2 

on ValidResponse2
   global t1, timeOutID, trialnum, stimlist 
   put the milliseconds into t2 
   put t2 - t1 into responseTime 
    
   cancel timeOutID 
    
   set the itemdelimiter to tab 
   saveData responseTime 
   saveChoice 
   set the lockscreen to true 
   hide image "Photo" 
   hide player "voices" 
   hide scrollbar "Slider" 
   hide scrollbar "slider2" 
   hide button "Next" 
   hide button "Next2"
   hide button "Replay" 
   hide image "fixation" 
   hide fld "EndofTime" 
   hide fld "EndofExperiment" 
   set the lockscreen to false 
    
   put trialnum into item 1 of line trialnum of stimlist 
    
   add 1 to trialnum 
   send "beginExperiment" to me in 10 milliseconds 
end ValidResponse2 


on timeout2 
   set the lockscreen to true 
   hide image "Photo" 
   hide player "voices" 
   hide scrollbar "Slider" 
   hide scrollbar "Slider2" 
   hide button "Next2" 
   hide button "Next"
   hide button "Replay" 
   set the lockscreen to false 
    
   show field "EndofTime" 
   wait 3 seconds 
   hide field "EndofTime" 
    
   set the itemdelimiter to tab 
   put trialnum into item 1 of line trialnum of stimlist 
   put listened into item 15 of line trialnum of stimlist 
   put "T-O" into item 16 of line trialnum of stimlist 
   put "T-O" into item 17 of line trialnum of stimlist 
   put "T-O" into item 18 of line trialnum of stimlist 
   put "T-O" into item 19 of line trialnum of stimlist 
   add 1 to trialnum 
    
   send "beginExperiment2" to me in 10 milliseconds 
end timeout2

on saveChoice
  set the itemdelimiter to tab
  if response = 1 then
    put the thumbpos of scrollbar "slider2" into item 17 of line trialnum of stimlist
    put the thumbpos of scrollbar "slider2" into ResponseVal
put listened into item 15 of line trialnum of stimlist
put ResponseVal-25 into item 19 of line trialnum of stimlist
if ResponseVal=25 then
  put "M" into item 18 of line trialnum of stimlist
  end if
if ResponseVal>25 then 
put "R" into item 18 of line trialnum of stimlist
  end if
  if ResponseVal<25 then 
  put "J" into item 18 of line trialnum of stimlist
  end if
end if  
end saveChoice

on saveData x
  set the itemdelimiter to tab
  put x into item 16 of line trialnum of stimlist
end saveData x


Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 6:53 pm

I think i know what I did, or didnt do. I didnt change all the "Imagenum" to "imagenameexp".

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 7:03 pm

I meant Imagename to imagenameexp (I thought I used 'imagename' earlier in the study for compiling the stimlist so I used imagenameExp instead of imagename).

Unfortunately, after making the changes - the image is still not showing up.

the imagenum part does seem to work though as the "slider" is moving back and forth in the directions programmed.

hmmmm

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 7:34 pm

When I look at the source of the image "photo" says "-25.bmp" indicating it is not getting the actual image name... yet it should put in the actual image name from "imagenameExp" - as this should have "item 6 of line trialnum of stimlist" in it...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Tue Nov 03, 2009 7:46 pm

Chibling,

did you change this line also?
put item 6 of line trialNum of stimList into imageName
in the begin experiment handler. If you didnt then you dont get a valid path in imageNameExp.
try it
regards
Bernd

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 8:21 pm

That did the trick,

Thank you Bernd and Regulae!

I will give this new code a run through to see if the hang up occurs.

-Brandon

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Post by bn » Tue Nov 03, 2009 8:51 pm

Chibling,
have a look at your scrollbar handler:
global stimlist, photopath, trialnum, imagenameexp

on scrollbardrag
put the thumbpos of scrollbar "slider2" into x
set the itemdelimiter to tab
set the filename of image "photo" to photopath&imagenameexp&"-"&x&".bmp"
end scrollbardrag
you could cut down on the globals and leave out the itemdelimiter and use the parameter that is provided by Rev to the scrollbardrag message.

Code: Select all

global photopath, imagenameexp 

on scrollbardrag x
  set the filename of image "photo" to photopath&imagenameexp&"-"&x&".bmp" 
end scrollbardrag 
And unless you use the scrollbar to manually set the images, that means if the scrollbar is just a visual cue to the progress of the test, then you would not have to set the image in the scrollbardrag handler at all, because you already did set the image in your Cycleimagedown/up handler and then you set the same image again in the scrollbardrag handler.
regards
Bernd

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Tue Nov 03, 2009 11:47 pm

It works well!

Even when my system is processing other things and slowing runtime down it does not result in a messed up scrollbar.

I will tune 'my' code tonight and probably use it tomorrow.

Thank you both!

Gotta love the Germans and Australians ;)

-Brandon

Chibling
Posts: 21
Joined: Thu Jul 16, 2009 9:05 pm

Post by Chibling » Wed Nov 04, 2009 2:52 am

Hello,

I just tested the code on a participant tonight and it worked flawlessly.

I owe you two my master's thesis!

Thank you Michael and Bernd, you prevented a mental break down :)

-Brandon

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am
Location: Australia

Post by Regulae » Thu Nov 05, 2009 6:17 am

G’day Brandon,

Glad to hear that things are progressing well. You have designed a very interesting experiment. I see that you have successfully extended the approach to cover beginExperiment2. I notice I forgot to apply “with messagesâ€

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”