# After KbCheck, continue to read the list during 800-1500 msec

**URL:** <https://psychtoolbox.discourse.group/t/after-kbcheck-continue-to-read-the-list-during-800-1500-msec/389>\
**Category:** Uncategorized\
**Created:** [November 26, 2012, 8:25am UTC](https://psychtoolbox.discourse.group/t/after-kbcheck-continue-to-read-the-list-during-800-1500-msec/389 "2012-11-26T08:25:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emiliecaspar](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emiliecaspar](https://psychtoolbox.discourse.group/u/emiliecaspar)\
**Post date:** [November 26, 2012, 8:25am UTC](https://psychtoolbox.discourse.group/t/after-kbcheck-continue-to-read-the-list-during-800-1500-msec/389/1 "2012-11-26T08:25:03Z")

</div>

Hello,  
  
Here there is a part of my script. I want that after participants push the keyboard, the script continue to read the external list (items) during 800 - 1500 msec (random).  
  
I have try this possibility :   
  
items=textread('HorlogeAlea.txt', '%s');   
nItems=length(items); % spécifie la longueur de la liste  
tex=zeros(1,nItems);%Textures  
  
Order=randi(length(items)):length(items) % premier stimulus aléatoire, puis suite de la liste  
  
 for i=Order  
 img=imread(items{i});  
 tex(i)=Screen('MakeTexture', w, img); %Faire les textures  
 end  
  
cycleRefresh=Screen('GetFlipInterval', w); %Spécifie le cyclerefresh  
vbl=Screen(w, 'Flip');  
  
start=GetSecs  
  
 for i=Order  
 Screen('drawtexture', w, tex(i))   
 vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
 KbCheck;   
 if KbCheck   
 while GetSecs-start \< 2  
 GetSecs  
 [KeyisDown, secs, keyCode, detlaSecs]=KbCheck  
 if strcmp(KbName(keyCode), 'm')==1  
 stop=GetSecs  
 break;  
 end  
 end  
 end  
 end  
  
The script runs, but without what I ask (certainly, it's not the good way).  
  
Secondly, if I want that Matlab choses between a lot a values from 800 to 1500 msec, do I create a list of value (e.g. timing), and specify GetSecs-start \< timing?  
  
Thank you very much,  
  
Emilie

---

<div class="post-metadata">

**Author:** ![emiliecaspar](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emiliecaspar](https://psychtoolbox.discourse.group/u/emiliecaspar)\
**Post date:** [November 26, 2012, 5:04pm UTC](https://psychtoolbox.discourse.group/t/after-kbcheck-continue-to-read-the-list-during-800-1500-msec/389/2 "2012-11-26T17:04:58Z")

</div>

No needs finally --\>  
That command functions :  
  
Timing = [1,2,3];  
TimingAlea=randi(3);  
Bla=Timing(TimingAlea)  
  
 j = i;  
 start = GetSecs;  
 while GetSecs-start \< Bla  
 GetSecs  
 j = j+1;  
 img=imread(stimuli{j});  
 texstim(j)=Screen('MakeTexture', w, img); %Faire les textures  
 Screen('drawtexture', w, texstim(j)) % Fait apparaitre les textures crées  
 vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
 end  
  
If that can help somebody, I post it here.  
  
-Emilie  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "emiliecaspar" \<emiliecaspar@...\> wrote:  
> \>  
> \> Hello,  
> \>   
> \> Here there is a part of my script. I want that after participants push the keyboard, the script continue to read the external list (items) during 800 - 1500 msec (random).  
> \>   
> \> I have try this possibility :   
> \>   
> \> items=textread('HorlogeAlea.txt', '%s');   
> \> nItems=length(items); % spécifie la longueur de la liste  
> \> tex=zeros(1,nItems);%Textures  
> \>   
> \> Order=randi(length(items)):length(items) % premier stimulus aléatoire, puis suite de la liste  
> \>   
> \> for i=Order  
> \> img=imread(items{i});  
> \> tex(i)=Screen('MakeTexture', w, img); %Faire les textures  
> \> end  
> \>   
> \> cycleRefresh=Screen('GetFlipInterval', w); %Spécifie le cyclerefresh  
> \> vbl=Screen(w, 'Flip');  
> \>   
> \> start=GetSecs  
> \>   
> \> for i=Order  
> \> Screen('drawtexture', w, tex(i))   
> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
> \> KbCheck;   
> \> if KbCheck   
> \> while GetSecs-start \< 2  
> \> GetSecs  
> \> [KeyisDown, secs, keyCode, detlaSecs]=KbCheck  
> \> if strcmp(KbName(keyCode), 'm')==1  
> \> stop=GetSecs  
> \> break;  
> \> end  
> \> end  
> \> end  
> \> end  
> \>   
> \> The script runs, but without what I ask (certainly, it's not the good way).  
> \>   
> \> Secondly, if I want that Matlab choses between a lot a values from 800 to 1500 msec, do I create a list of value (e.g. timing), and specify GetSecs-start \< timing?  
> \>   
> \> Thank you very much,  
> \>   
> \> Emilie  
> \>
