# How to update text field contents during looping process

**URL:** <https://www.ruby-forum.com/t/how-to-update-text-field-contents-during-looping-process/139298>\
**Category:** Ruby\
**Created:** [June 2, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/how-to-update-text-field-contents-during-looping-process/139298 "2008-06-02T18:51:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [June 2, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/how-to-update-text-field-contents-during-looping-process/139298/1 "2008-06-02T18:51:16Z")

</div>

I am running a loop over AppleScript files in a directory tree. Each  
time through  
the loop “osadecompiles” the script and adds the script text to an  
array. When  
it is through it populates a table.

What I have been attempting to do is update a text field with the  
current iteration.

I am using the following code but I have tried many variations.

I have tried with and without the Thread. It _does_ log to the console  
through each  
iteration just not the window.

def update\_run\_count  
Thread.new do  
text = “Processing #{@c} of #{@file\_count}”  
puts text  
@text\_field.setStringValue(text)  
@text\_field.setNeedsDisplay(true)  
@text\_field.setTextColor(NSColor.redColor)  
end  
end

Thanks,

Craig
