Floppy Posted July 18, 2012 Share Posted July 18, 2012 $IniAppSearchedQueriesPath = @ScriptDir&"\searched_queries.txt" $SearchedQueriesFileOpen = FileOpen($IniAppSearchedQueriesPath, 1) $SearchedQueriesFileRead = FileRead($SearchedQueriesFileOpen) MsgBox(0,'',$SearchedQueriesFileRead&@CRLF&@extended&@CRLF&@error) File searched_queries.txt41545416451654 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 More sharing options...
bogQ Posted July 18, 2012 Share Posted July 18, 2012 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 connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
Floppy Posted July 18, 2012 Author Share Posted July 18, 2012 O_O If I use 0, it works!!! I want to use 1 because I need both to read and write the file. How can I do this? Link to comment Share on other sites More sharing options...
bogQ Posted July 18, 2012 Share Posted July 18, 2012 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 connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
Floppy Posted July 18, 2012 Author Share Posted July 18, 2012 But why should I open the same file twice??? In my opinion, this is a bug. If I open the file for writing (1), it should be opened also for reading (0) because 1 + 0 = 1 Link to comment Share on other sites More sharing options...
rvn Posted July 18, 2012 Share Posted July 18, 2012 (edited) Thats not bug,,, please read help file...For write and read file from same handler u can use FileSetPosBut why should I open the same file twice???Safer, Simpler,,, atleast for me Edited July 18, 2012 by rvn Link to comment Share on other sites More sharing options...
Bowmore Posted July 18, 2012 Share Posted July 18, 2012 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 More sharing options...
Floppy Posted July 19, 2012 Author Share Posted July 19, 2012 Bowmore thank you for your reply. However I think I will open the file twice because it's a simpler solution. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now