Jump to content

[HELP] File read all lines except last 1


Recommended Posts

Hello scripters :) i got another problem reading all lines in txt file except the last one.

I dont want to write how many lines to read just reading all except the last whatever how many it is.

My efforts:

#include <file.au3>
$file = @ScriptDir & "\x.txt"
$ReadLines = FileReadLine($file)

Local $Read
_FileReadToArray($file, $Read)
For $i = 1 To $Read - 1 ; with-1 or without-1 the result is the same
MsgBox(0, $i, $Read - 1)
Next

Question here: "Why first msgbox title is "1" ? and how can i avoid that?"

#include <file.au3>
$file = @ScriptDir & "\x.txt"
$ReadLines = FileReadLine($file)

Local $Read
_FileReadToArray($file, $Read)
For $i = 1 To $Read
MsgBox(0, $i, $Read[0] -1) ; here in msg's text resolved but in title not :D i think the problem from $i ??
Next

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

Try it this way - For $i = 1 To $Read[0] - 1

example:

#include <file.au3>
Local $Read, $file = "x.txt"

_FileReadToArray($file, $Read)

For $i = 1 To $Read[0] - 1
    ConsoleWrite($i & " - " & $Read[$i] & @LF)
Next

x.txt

line 1
line 2
line 3
line 4
line 5

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Awesome!!!! it's working !! :)

Thanks somdcomputerguy

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

@kylomas

mmm... you're right ! thanks.:)

@somdcomputerguy

thanks again. ;)

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...