Directories and Files processing

Discussion in 'Ruby' started by Albert Lao-an, Dec 5, 2008.

  1. I am trying to use Shoes to iterate files in a directory and I just
    cannot have it work:

    files = Dir.entries("root")
    files.each {|f|
    @data = IO.read(f)
    tokens = tokenize(@data)
    next_token
    while not @current_token.nil?
    read_input
    next_token
    end
    @tokens = nil
    @data = nil

    }


    ##@data = IO.read("C:\\Shoes\\TxtBrx5\\root\\goo")
    ##@tokens = tokenize(@data)
    ##next_token
    ##while not @current_token.nil?
    ##read_input
    ##next_token
    ##end
    ##@tokens = nil
    ##@data = nil

    Apparently, those in comment work but iteration does not. Tried several
    methods with Dir with no success.

    Thanks
    --
    Posted via http://www.ruby-forum.com/.
     
    Albert Lao-an, Dec 5, 2008
    #1
    1. Advertising

  2. Is it an option to do something like this?
    Dir.chdir("root")
    Dir.glob('*') do |f|
    (enter stuff here)
    end

    Albert Lao-an wrote:
    > I am trying to use Shoes to iterate files in a directory and I just
    > cannot have it work:
    >
    > files = Dir.entries("root")
    > files.each {|f|
    > @data = IO.read(f)
    > tokens = tokenize(@data)
    > next_token
    > while not @current_token.nil?
    > read_input
    > next_token
    > end
    > @tokens = nil
    > @data = nil
    >
    > }
    >
    >
    > ##@data = IO.read("C:\\Shoes\\TxtBrx5\\root\\goo")
    > ##@tokens = tokenize(@data)
    > ##next_token
    > ##while not @current_token.nil?
    > ##read_input
    > ##next_token
    > ##end
    > ##@tokens = nil
    > ##@data = nil
    >
    > Apparently, those in comment work but iteration does not. Tried several
    > methods with Dir with no success.
    >
    > Thanks
     
    Aldric Giacomoni, Dec 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Finkel
    Replies:
    0
    Views:
    499
    Joel Finkel
    Sep 12, 2003
  2. Jeffry van de Vuurst
    Replies:
    2
    Views:
    539
    Jeffry van de Vuurst
    Jul 30, 2003
  3. kkirtac
    Replies:
    7
    Views:
    347
    Jerry Coffin
    Aug 4, 2007
  4. Adam Petrie
    Replies:
    8
    Views:
    319
    Adam Petrie
    Oct 11, 2004
  5. Ron Smith
    Replies:
    5
    Views:
    155
    Michele Dondi
    Nov 2, 2004
Loading...

Share This Page