toofat Posted May 6, 2011 Posted May 6, 2011 (edited) I would be grateful if someone could explain to me why function "_Test2()" doesn't consume much memory while function "_Test1()" uses more and more memory. Functions should do the same thing. This happens in the case when a prerequisite is met so please do that.Please run the script with "_Test1()" and "_Test2()" function and then observe the Memory usage through "Task Manager" in both cases. Once again, would be grateful if someone could explain.Prerequisite ... create file "@ScriptDir & '\test.txt'" and deny yourself read/write rights on it.; Prerequisite ... create file "@ScriptDir & '\test.txt'" and deny yourself read/write rights on it. ; File can be empty or have one line of TXT or whatever ... Dim $t = 0, $f = 1 If MsgBox (262180, 'TEST', 'Do you wish to use function "_Test2"?') = 6 Then $f = 2 While 'TEST' Switch $f Case 1 _Test1(@ScriptDir & '\test.txt') Case 2 _Test2(@ScriptDir & '\test.txt') EndSwitch If @error AND MsgBox (262144, 'TEST', 'Prerequisite not met. Exiting.', 5) Then ExitLoop If $t = 1000 AND MsgBox (262180, 'TEST', 'Do you wish to STOP?') = 6 Then ExitLoop $t += 1 If $t > 1000 Then $t = 0 Sleep (5) WEnd Exit Func _Test1($File = '') If $File = '' OR NOT FileExists ($File) Then Return SetError (1, 0, 'ERROR') $FileHandle = FileOpen ($File, 0) FileReadLine ($FileHandle, 1) FileClose ($FileHandle) Return SetError (0, 0, '') EndFunc ;=>_Test1 Func _Test2($File = '') If $File = '' OR NOT FileExists ($File) Then Return SetError (1, 0, 'ERROR') FileReadLine ($File, 1) Return SetError (0, 0, '') EndFunc ;=>_Test2 Edited May 6, 2011 by toofat
Tvern Posted May 6, 2011 Posted May 6, 2011 I can replicate the problem under Win7 x64. FileOpen is returning -1, indicating failure, but for some reason memory is used. Obviously FileReadLine and FileClose will just plain fail with the invalid handle. I can't find an open ticket on it, but it looks like a bug.
Balay2b Posted May 6, 2011 Posted May 6, 2011 friends.... How can i get text of the cursor position with out click on it By using cursor position only
toofat Posted May 6, 2011 Author Posted May 6, 2011 Well yes, that is also what i think but a stupid bug ... More correct function of the two is not working ... Also, function _Test2() is the same as _Test1() but what if you wanted to do something like this ... $FileHandle = FileOpen ($File, 2) FileWriteLine ($FileHandle, 1) FileClose ($FileHandle) OK, I will report it ...
hannes08 Posted May 6, 2011 Posted May 6, 2011 friends.... How can i get text of the cursor position with out click on itBy using cursor position onlyfirst ... get your own post ... Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
toofat Posted May 6, 2011 Author Posted May 6, 2011 Also one more think, same thing happens if you do this $FileHandle = FileOpen ($File, 0) If $FileHandle = -1 Then Return SetError (1, 0, 'ERROR') FileReadLine ($FileHandle, 1) FileClose ($FileHandle) So it is not only in the case of the wrong FileHandle. It is not "FileReadLine" that fails, it is FileOpen/FileClose combination ...
Tvern Posted May 6, 2011 Posted May 6, 2011 Actually it's just FileOpen. As the other functions are not passed a valid handle, they do nothing.
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