Sign in to follow this  
Followers 0
Greenseed

Fileread()

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



fileread($$_fspath


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

good catch plato

i have the beta AutoIt 3.1.1.92.

it says

FileRead ( filehandle or "filename" [, count] )

and the demo works

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

many Thx! this solve my probleme!


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0