Guest Abalone Posted June 25, 2007 Share Posted June 25, 2007 When I read a big file (eg 500K) using fileread without specifying the size. It will go into an endless loop $filehandle=FileOpen("Source",4) $filehandle2=fileopen("Target",2) While 1 $buffer=FileRead($filehandle,65534) //It won't work if I use "$buffer=FileRead($filehandle)" If @error = -1 Then ExitLoop filewrite($filehandle2,HTMLtoCSV($buffer)) WEnd FileClose($filehandle) FileClose($filehandle2) Did I do something wrong? Thank you! Link to comment Share on other sites More sharing options...
/dev/null Posted June 25, 2007 Share Posted June 25, 2007 Did I do something wrong? Thank you!yes. Your error check does not take care of all possible error values.From help file: FileRead()Return ValueSuccess: Returns the binary/string read. Special: Sets @error to -1 if end-of-file is reached. Failure: Sets @error to 1 if file not opened in read mode or other error. Sets @error to 2 if count not defined for file open in raw read mode. <== THIS is your problem! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Fabry Posted June 25, 2007 Share Posted June 25, 2007 When I read a big file (eg 500K) using fileread without specifying the size. It will go into an endless loopIf you don't specify the size, it reads completaly the file and it doesn't make errors, then it will go into endless loop. A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center] Link to comment Share on other sites More sharing options...
AutoItKing Posted June 25, 2007 Share Posted June 25, 2007 Use FileGetSize to fix this problem. http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
dabus Posted June 26, 2007 Share Posted June 26, 2007 Wouldn't it be easier to read everything to an array an do the writing after that? Try this (I think it's from SmOke_N): Func _Txt2Array($a) Local $Array = StringSplit(StringStripCR(FileRead($a)), @LF) Return $Array EndFunc ;==>_Txt2Array Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2007 Developers Share Posted June 27, 2007 Nopt a bug report but Support request. - moved- SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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