Jump to content

Please help with FileReadLIne


Recommended Posts

Hello everyone

Please can anyone tell me what's wrong with this script?

#include <File.au3>

#cs

Trim list to 250 characters

#ce

$fileo = FileOpen ("list.txt", 32)

$filer = FileRead ($fileo)

$count = _FileCountLines (@ScriptDir & "\list.txt")

$filew = FileOpen ("list2.txt", 33)

For $i = 1 to $count

$line = FileReadLine ($filer, $i)

MsgBox (0, "", $line, 0)

$len = StringLen ($line)
$len2 = $len - 250

$foo = StringTrimRight ($line, $len2)

FileWrite ($filew, $foo)

Next

The "list.txt" is a plain text file with a few lines of text in it.  It's suppose to give me a MsgBox with each line in it.  But I get blank MsgBox'es, and the output file list2.txt is empty.  I've tried other "list.txt" files, and I've tried different file encodings.

Thanks

Samuel

Link to comment
Share on other sites

try this way

#include <File.au3>

#cs

Trim list to 250 characters

#ce

$fileo = FileOpen ("list.txt", 32) ; read mode

; $filer = FileRead ($fileo) ; ?? not needed

$count = _FileCountLines (@ScriptDir & "\list.txt")

$filew = FileOpen ("list2.txt", 33) ; write mode

For $i = 1 to $count

$line = FileReadLine ($fileo) ; read next line

MsgBox (0, "", $line)

$len = StringLen ($line)
$len2 = $len - 250

$foo = StringTrimRight ($line, $len2)

FileWrite ($filew, $foo) ; maybe you need FileWriteLine ?

Next

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...