AFXProdigy Posted July 20, 2011 Posted July 20, 2011 Hi everyone, im working on a script that creates a file named xxxxx0.csv, and if already exists then name it xxxxx1.csv and so on. problem is the loop freezes every time.. here is the code: $num = 0 $name = @ComputerName & "_perfmon_" & $num $path = '"C:\PerfLogs\' & $name & '.csv"' Do sleep(50) $num += 1 $name = @ComputerName & "_perfmon_" & $num ;redundant? i try without this two lines anyways $path = '"C:\PerfLogs\' & $name & '.csv"' Until not FileExists($path) rest of the code.. i also try with While $num = 0 $name = @ComputerName & "_perfmon_" & $num $path = '"C:\PerfLogs\' & $name & '.csv"' while 1 sleep(50) If not FileExists($path) Then ExitLoop Else $num += 1 $name = $computername & "_perfmon_" & $num ;same with and without $path = '"C:\PerfLogs\' & $name & '.csv"' ;same with and without EndIf WEnd also tried this.. $num = 0 $name = @ComputerName & "_perfmon_" & $num $path = '"C:\PerfLogs\' & $name & '.csv"' $var = FileExists($path) While $var = 1 $num += 1 $name = @ComputerName & "_perfmon_" & $num $path = '"C:\PerfLogs\' & $name & '.csv"' $var = FileExists($path) WEnd When the file does not exist the program works fine but when it does the program freezes. i try putting a MsgBox right after the while for debugging and it never comes up.. so the program is not looping, just freezing.. any ideas?? thanks!!
ahmet Posted July 20, 2011 Posted July 20, 2011 Maybe it is because your file path contains '"' and they are not allowed in filename.
MvGulik Posted July 20, 2011 Posted July 20, 2011 Mmm. Try not to include those ["] quotes with FileExists()$path = '"C:\PerfLogs\' & $name & '.csv"'$path = 'C:\PerfLogs\' & $name & '.csv' Add them when needed. -> Run*() "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
JohnOne Posted July 20, 2011 Posted July 20, 2011 This line looks wierd to me $path = '"C:\PerfLogs\' & $name & '.csv"' Try $path = 'C:\PerfLogs\' & $name & '.csv' AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
AFXProdigy Posted July 20, 2011 Author Posted July 20, 2011 Maybe it is because your file path contains '"' and they are not allowed in filename.lol that do the magicwonder why scite dont warn about this.. nor it makes the function terminate and @error something.thanks a lot!
AFXProdigy Posted July 20, 2011 Author Posted July 20, 2011 Mmm. Try not to include those ["] quotes with FileExists()$path = '"C:\PerfLogs\' & $name & '.csv"'$path = 'C:\PerfLogs\' & $name & '.csv' Add them when needed. -> Run*() This line looks wierd to me $path = '"C:\PerfLogs\' & $name & '.csv"' Try $path = 'C:\PerfLogs\' & $name & '.csv' you are both right also. thanks for the answers!
JohnOne Posted July 20, 2011 Posted July 20, 2011 wonder why scite dont warn about this.. nor it makes the function terminate and @error something.Not certain about the answer to that, but the syntax you had is valid, just not fit for purpose. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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