Jump to content

Fileread()


Recommended Posts

this simple script do not know why??? im unable to readfile

error is set to -2 by fileread() in the help file, nothing tel me that fileread can set error to -2

#include <file.au3>



$texttosearch = InputBox("Find Texte","Le Text Rechercher","boot","",200,80,200,200)

;Set Global Path
$_fspath = "c:"

;List File To Array
$FileList=_FileListToArray($_fspath,"*",1)

;if error msgbox
If Not IsArray($FileList) and @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf


for $x = 1 to $filelist[0]
    Local $_fsfhandle
    Local $_fsreadfile
    $_fsfilesize = FileGetSize($_fspath & "\" & $filelist[$x])
    if $_fsfilesize < 10000000 Then
        $_fsfhandle = fileopen($_fspath & "\" & $filelist[$x], 0)
        $_fsreadfile = fileread($$_fspath & "\" & $filelist[$x])
        MsgBox(262144,'Debug line ~26','Selection:' & @lf & '$_fsreadfile' & @lf & @lf & 'Return:' & @lf & $_fsreadfile & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
        if stringinstr($_fsreadfile,$texttosearch) Then msgbox(0,"StringFound" , $filelist[$x])
        fileclose($_fsfhandle)
    EndIf

Next

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Link to comment
Share on other sites

BTW, isn't there a problem with Count parameter? I just faced the problem with FileRead and it looks, the Count is not "optional"? At least not in the latest AutoIt 3.1.1.92. I had to use "Count" argument in my script, otherwise it doesn't work.

Edited by odklizec
Link to comment
Share on other sites

Strange, after using this code..

$chars = FileRead("E:\temp\test.txt")

I got this error..

FileRead() [built-in] called with wrong number of args."

while this works OK..

$chars = FileRead("E:\temp\test.txt",FileGetSize("E:\temp\test.txt"))

But if I understand the FileRead function correctly, the COUNT argument should not be required if I need to read entire file?

It looks another user already confirmed this FileRead problem here..

Edited by odklizec
Link to comment
Share on other sites

Yes, there are currently problems with the beta's FileRead(), however you are receiving the error you mention because you are running the release version.

To fix this you need to run Start > Programs > AutoIt v3 > Beta > Toggle AU3 Beta.

Edit: Typo.

Edited by LxP
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...