# For loop error

**URL:** <https://psychtoolbox.discourse.group/t/for-loop-error/1910>\
**Category:** Uncategorized\
**Created:** [November 8, 2007, 1:33am UTC](https://psychtoolbox.discourse.group/t/for-loop-error/1910 "2007-11-08T01:33:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [November 8, 2007, 1:33am UTC](https://psychtoolbox.discourse.group/t/for-loop-error/1910/1 "2007-11-08T01:33:35Z")

</div>

I have a for loop which should work fine.  
  
Basically in this loop I draw the same image over and over using DrawTexture.  
  
It works fine on the first run through the loop, but any subsequent runs give me this error:  
  
  
error  
INTERNAL PSYCHTOOLBOX ERROR  
 error: PsychError\_InvalidWindowRecord  
 general description: An Invalid window record was referenced.  
 module name: Screen  
 subfunction call: DrawTexture  
 file name:   
/Users/kleinerm/projects/OpenGLPsychtoolbox/trunk/PsychSourceGL/Projects/MacOSX/P  
sychToolbox/../../../Source/Common/Screen/WindowHelpers.c  
 function name: PsychCheckIfWindowRecordIsValid  
 line number: 97  
??? (null)  
  
Error in ==\> FinanceGame at 218  
 Screen('DrawTexture', w, probe.imagetex, [], probe.sRect);  
  
  
  
Can anyone shed some light on what the problem might be?

---

<div class="post-metadata">

**Author:** ![franswcornelissen](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@franswcornelissen](https://psychtoolbox.discourse.group/u/franswcornelissen)\
**Post date:** [November 8, 2007, 4:13pm UTC](https://psychtoolbox.discourse.group/t/for-loop-error/1910/2 "2007-11-08T16:13:51Z")

</div>

The error suggest you may have closed the texture after the first run through.  
  
Gr.  
Frans  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "bbushongjr" \<bbushongjr@...\> wrote:  
> \>  
> \> I have a for loop which should work fine.  
> \>   
> \> Basically in this loop I draw the same image over and over using DrawTexture.  
> \>   
> \> It works fine on the first run through the loop, but any subsequent runs give me this   
> error:  
> \>   
> \>   
> \> error  
> \> INTERNAL PSYCHTOOLBOX ERROR  
> \> error: PsychError\_InvalidWindowRecord  
> \> general description: An Invalid window record was referenced.  
> \> module name: Screen  
> \> subfunction call: DrawTexture  
> \> file name:   
> \> /Users/kleinerm/projects/OpenGLPsychtoolbox/trunk/PsychSourceGL/Projects/  
> MacOSX/P  
> \> sychToolbox/../../../Source/Common/Screen/WindowHelpers.c  
> \> function name: PsychCheckIfWindowRecordIsValid  
> \> line number: 97  
> \> ??? (null)  
> \>   
> \> Error in ==\> FinanceGame at 218  
> \> Screen('DrawTexture', w, probe.imagetex, [], probe.sRect);  
> \>   
> \>   
> \>   
> \> Can anyone shed some light on what the problem might be?  
> \>
