cparadis Posted November 13, 2008 Share Posted November 13, 2008 Here is my code. I don't know whats wrong. So i have write some comments, a lot more easy to read. I want to change the date for a file, with this code. But it seems like it doesn't work. expandcollapse popup;Make the file iniwrite("testing.ini", "test", "test", "test") Dim $test, $data, $date, $x ;Set the directory and file path. $test = @ScriptDir & "\testing.ini" ;Help text. $text = "Change time for a file" & @cr & @cr & "YYYY MM DD HH:MM:SS" & @cr & @cr & "Example:" & @cr & @cr & "2008 06 02 13:02:23" ;The inputbox. $data = inputbox("Change time", $text , "2008 06 02 13:02:23", "", "100", "200") ;If error is clean if @error = 0 Then ;If the line is 19 character. if StringLen($data) = 19 Then ;Remove space and : $date = StringReplace($data, chr(32), "") $date = StringReplace($data, chr(58), "") ;Set the date for the file. Modified, Created and Accessed. for $x = 0 to 2 FileSetTime($test, $date, $x) ;If something is wrong with settime. if @error = 0 Then MsgBox(0, "", "error") EndIf Next ;If something is wrong with the data. Else msgbox(0, "", "Error") Endif EndIf Link to comment Share on other sites More sharing options...
LarryDalooza Posted November 13, 2008 Share Posted November 13, 2008 study these two lines... $date = StringReplace($data, chr(32), "") $date = StringReplace($data, chr(58), "") therein is your mistake... $date ... $data Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
LarryDalooza Posted November 13, 2008 Share Posted November 13, 2008 To debug this you can always MsgBox() your variable before the failing Function to see if your passed data is valid. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
cparadis Posted November 13, 2008 Author Share Posted November 13, 2008 (edited) To debug this you can always MsgBox() your variable before the failing Function to see if your passed data is valid. Lar. Thanks. Now i see where the problem is. $date = StringReplace($data, chr(32), "") $date = StringReplace($data, chr(58), "") And that will be $date. Thanks for the quick help. Seems like the settime will not work correctly. Got error for it. I can't see more mistakes in the code. expandcollapse popup;Make the file iniwrite("testing.ini", "test", "test", "test") Dim $test, $data, $date ;Set the directory and file path. $test = @ScriptDir & "\testing.ini" ;Help text. $text = "Change time for a file" & @cr & @cr & "YYYY MM DD HH:MM:SS" & @cr & @cr & "Example:" & @cr & @cr & "2008 06 02 13:02:23" ;The inputbox. $data = inputbox("Change time", $text , "2008 06 02 13:02:23", "", "100", "200") ;If error is clean if @error = 0 Then ;If the line is 19 character. if StringLen($data) = 19 Then ;Remove space and : $date = StringReplace($data, chr(32), "") $date = StringReplace($date, chr(58), "") ;Set the date for the file. Modified, Created and Accessed. for $x = 0 to 2 FileSetTime($test, $date, $x) ;If something is wrong with settime. if @error = 0 Then MsgBox(0, "", "error") EndIf Next ;If something is wrong with the data. Else msgbox(0, "", "Error") Endif EndIf Edited November 13, 2008 by cparadis 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