www.webdeveloper.com
Results 1 to 3 of 3

Thread: read txt file line by line

  1. #1
    Join Date
    Feb 2010
    Location
    NJ
    Posts
    6

    Question read txt file line by line

    Hi,
    How do I read a local text file line by line, one line at a time.
    I got upto opening a file, and can read whole file at a time. But I want to read just one line at a time. May be have a counter of lenght of the file and read only the counter number line at a time.

    <SCRIPT language=JavaScript>
    var fso = new ActiveXObject( 'Scripting.FileSystemObject' );
    f = fso.OpenTextFile( "c:\\mytextfile.txt", 1 );
    //txt = f.Readall;
    txt = f.Readline;
    f.close();
    write(txt);
    </SCRIPT>


    Thanks

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    This is an ActiveX problem, not a JavaScript one

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    txt = String(f.Readline).split(/\r?\n/)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles