Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Directories and Files processing

Reply
Thread Tools

Directories and Files processing

 
 
Albert Lao-an
Guest
Posts: n/a
 
      12-05-2008
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/.

 
Reply With Quote
 
 
 
 
Aldric Giacomoni
Guest
Posts: n/a
 
      12-05-2008
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directories and Physical directories Paul M Fin MCAD 4 06-27-2008 07:50 PM
sequantial processing of files of several directories kkirtac C++ 7 08-04-2007 07:44 PM
Extracting Directories and Sub Directories and Counting Ron Smith Perl Misc 5 11-02-2004 11:23 PM
Getting all directories/files from current directory and using -d flag for the directories Adam Petrie Perl Misc 8 10-11-2004 01:28 PM
How to map Project directories to Production sub-directories Joel Finkel ASP .Net 0 09-12-2003 06:47 PM



Advertisments