Jump to content

FileRead not working


Recommended Posts

$IniAppSearchedQueriesPath = @ScriptDir&"\searched_queries.txt"
$SearchedQueriesFileOpen = FileOpen($IniAppSearchedQueriesPath, 1)

$SearchedQueriesFileRead = FileRead($SearchedQueriesFileOpen)
MsgBox(0,'',$SearchedQueriesFileRead&@CRLF&@extended&@CRLF&@error)

File searched_queries.txt

41545416451654
415415451522106
6556498405106
641504546415
05454684684651
351
64654654654
5465464
61
545431
545

Hello,

I have a problem with the script above.

FileRead doesn't read the file content, but returns no errors.

Can someone help me, please?

Thank you

Bye

Link to comment
Share on other sites

ofc it doesn't read the file content

FileOpen($IniAppSearchedQueriesPath, 1)

is for writing

FileOpen($IniAppSearchedQueriesPath, 0)

is for reading

change that line and c if it works

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

if your not working with alot of data

when you read it in mode 0, change or add data while data is still in variable.

after that open with FileOpen on mode

2 = Write mode (erase previous contents)

and write it all in one shot

dont forgot to use

FileClose($file)

every time you try to reopen file in diffrent mod

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Thats not bug,,, please read help file...

For write and read file from same handler u can use FileSetPos

But why should I open the same file twice???

Safer, Simpler,,, atleast for me :) Edited by rvn
Link to comment
Share on other sites

if you only want to open the file once then you need to use filesetpos() to set the position of of the next read or write. Opening a file with option 1 sets the position at the end of the file so when you read the files it tries to read the data beyond the end of the file and of course there is no data to read in that position. If you set the file position to the start of the file and then read it you will get the contents as you expected. The the position is specified in Bytes/Chars.

Example:

$IniAppSearchedQueriesPath = @ScriptDir&"searched_queries.txt"
$SearchedQueriesFileOpen = FileOpen($IniAppSearchedQueriesPath, 1)
FileSetPos($SearchedQueriesFileOpen,1,0)
$SearchedQueriesFileRead = FileRead($SearchedQueriesFileOpen)
MsgBox(0,'',$SearchedQueriesFileRead&@CRLF&@extended&@CRLF&@error)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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...