/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 07.2010 — This is an ActiveX problem, not a JavaScript one
Copy linkTweet thisAlerts:
@rnd_meJul 07.2010 — [CODE]txt = String(f.Readline).split(/r?n/)[/CODE]
×

Success!

Help @marked9 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...