Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: File Object, ReadLine method  (Read 4186 times)

0 Members and 1 Guest are viewing this topic.

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
File Object, ReadLine method
« on: January 10, 2012, 10:40:51 AM »

It's not really clear how ReadLine() method works.
It reads "a" line...but how can i read each line of my file? There is an index to pass as a parameter for this method?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: File Object, ReadLine method
« Reply #1 on: January 10, 2012, 06:46:44 PM »

The file is read sequentially. You open the file, ReadLine() will read the first line. Second call to ReadLine() will read the second line etc.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: File Object, ReadLine method
« Reply #2 on: January 11, 2012, 09:18:36 AM »

Wow, very nice and simple!
No nextLine, hasLine, blablaLine method :D  Thankyou!
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: File Object, ReadLine method
« Reply #3 on: January 12, 2012, 01:51:52 PM »

Sorry I forgot to ask one more thing about this,
how can i write a while "there is line" {file.ReadLine()} cicle?

Is correct to write something like
(while file.ReadLine())
 
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: File Object, ReadLine method
« Reply #4 on: January 15, 2012, 02:16:20 PM »

You can do something like this:

Code: WME Script
  1. while (true)
  2. {
  3.   var line = file.ReadLine();
  4.   if (line == null) break;
  5.  
  6.   // process line here
  7. }
  8.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: File Object, ReadLine method
« Reply #5 on: January 15, 2012, 05:40:55 PM »

right! Thank you! ;)
Logged
 

Page created in 0.04 seconds with 22 queries.