macromedia.director.lingo
[Top] [All Lists]

Re: Problem at read files

Subject: Re: Problem at read files
From: "fazstp"
Date: Tue, 24 Feb 2009 19:59:27 +0000 UTC
Newsgroups: macromedia.director.lingo

This basic example worked for me. Really need to see more of your code to work 
out why it isn't working.

 .

 on getRandom
   if NOT ( ilk( _global.file_list ) = #list ) then
     _global.file_list = getFiles()
   end if
   
   if NOT count( _global.file_list ) then
     alert( "No valid files" )
   end if
   
   fileio_instance = _global.file_list[random( _global.file_list.count )]
   
   if ( fileio_instance.getPosition() = fileio_instance.getLength() ) then
     fileio_instance.setPosition( 0 )
   end if
   
   return fileio_instance.readLine()
   
 end getRandom

 on getFiles
   file_path = _movie.path
   file_name = "Test"
   file_list = []
   
   repeat with n = 1 to 10
     fileio = xtra( "FileIO" ).new()
     fileio.openFile( file_path & file_name & n & ".txt", 1 )
     
     if ( fileio.status() = 0 ) then
       file_list.add( fileio )
     end if
   end repeat
   
   return file_list
   
 end getFiles


<Prev in Thread] Current Thread [Next in Thread>