Re: Sleep




On 19.12.2008, at 01:21 , Adam Steinfurth wrote:

This program is very simple. It is suppose to load in the text
file, load
each character into an array, then print out the array one letter at a
time. It is supposed to wait 1 second each time it prints. This
freezes
every time I run it. Any ideas?

Adam


class Slow_Array

def array_split
@f = File.open('Text_for_TextReader.txt','r') do |f|
f.gets.scan(/\w/)
end
end

def print_and_wait
@f.each {
|i|
print i
sleep 1
}
end

end

#-------------------------------------------------
# Main logic
TextReader = Slow_Array.new

# Bring file into program
TextReader.array_split

# Print each character, waiting one second in between each printing
TextReader.print_and_wait

--
Put your computer to work.
www.volunteerathome.com


It doesn't freeze, but the output is buffered so it appears that way.
try adding a flush:

print i
STDOUT.flush
sleep 1


einarmagnus




.



Relevant Pages

  • Re: Sleep
    ... each character into an array, then print out the array one letter at a ... def print_and_wait ... # Print each character, waiting one second in between each printing ...
    (comp.lang.ruby)
  • Sleep
    ... It is suppose to load in the text file, ... each character into an array, then print out the array one letter at a ... def print_and_wait ... # Print each character, waiting one second in between each printing ...
    (comp.lang.ruby)
  • Re: Need help with textboxes
    ... character into the input box. ... one of assigning the reference to a variable: ... All forms and their children are stored in an array ... No. Bracket property accessors allow their argument to be any string value. ...
    (comp.lang.javascript)
  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • Re: Pointer
    ... require in input a pointer char: ... unsafe public static extern int OpenFile; ... What is it pointing to exactly, is it pointing to a "Unicode character" array or is it pointing to a "Single byte character" array or is it pointing to something else? ...
    (microsoft.public.dotnet.languages.csharp)