Systems By Posted July 6, 2006 Share Posted July 6, 2006 Hi everyone. I can't figure out what is wrong with my code. Here is the code I am using: expandcollapse popup#include<File.au3> $tempdir3=("C:\Temp\TempDir.txt") $homepcbudir=("C:\HomeBackups\") $bckupextdirhome=("F:\HomeBackups\") Dim $aRecords5 ProgressOn("Automated System Maintenance", "running processes","0 percent", 555, 555) $pbar = 15 sleep(1000) ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Searching") Sleep(1000) Run("cmd.exe") ; Wait until program active WinWaitActive("C:\WINNT\system32\cmd.exe") $pbar = 30 sleep(1000) ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Searching") Send("F:{enter}") sleep(1000) Send("CD F:\HomeBackups{enter}") sleep(1500) Send("dir /a /o-d /b > C:\temp\tempdir.txt{enter}") Sleep(1500) Send("exit {enter}") If Not _FileReadToArray($tempdir3, $aRecords5) Then MsgBox(4096, "Error", "Error reading Office PC backup log" & @error) Exit $pbar = 100 ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete") Exit EndIf $pbar = 60 ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Copying Files") For $x5 = 1 to 4 If Not FileExists($bckupextdirhome &$aRecords5) Then MsgBox(64, 'Info', 'File Does not exist') $aRecords5[$x5] = StringStripWS($aRecords5[$x5],3) $pbar = 80 ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Copying Files") If $aRecords5[$x5] <> "" Then Do FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir) Sleep(5000) SplashTextOn("Moving",$bckupextdirhome & $aRecords5[$x5] & " to Home Backup Directory on PC", 500, 250) Sleep(3000) SplashOff() Sleep(1000) Until Not FileExists($bckupextdirhome & $aRecords5[$x5]) ;SplashTextOn("Autobackup", "Deleting " & $home & $aRecords[$x], 200, 150) Sleep(200) ;SplashOff() EndIf Next $pbar = 100 ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete") Sleep(5000) ProgressOff() If I change this line FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir) to this line FileCopy($bckupextdirhome & $aRecords5[$x5], $homepcbudir) I only get the first file transferred then the program keeps splashing the same file over and over again and gets stuck in an infinite loop. If I move the file instead, the program works just fine. Also, can anyone tell why this part of my code If Not _FileReadToArray($tempdir3, $aRecords5) Then MsgBox(4096, "Error", "Error reading Office PC backup log" & @error) Exit $pbar = 100 ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete") Exit EndIf is not being seen if there is no file to read to an array? Instead, I get this error message that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any help would be appreciated. Arvin Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 6, 2006 Moderators Share Posted July 6, 2006 Your in a loop that says to continue until the file doesn't exist anymore, when you "FileMove()", the file no longer exists, when you "FileCopy()" the original file is still there, so it continues to loop. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skruge Posted July 6, 2006 Share Posted July 6, 2006 Welcome to the forums! If I change this line ... to this line ... I only get the first file transferred then the program keeps splashing the same file over and over again and gets stuck in an infinite loop. If I move the file instead, the program works just fine.Most likely the file exists, so it won't move again (won't overwrite). Try this: FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir, 1)oÝ÷ Ú«¨µéÚoÝ÷ Ø l¢Ç§v)à쬶+'ßÛkyÊ&éÝyÔ¢±·µêۺاʫq«×©emçh觢w¥wºÚ"µÍ[ØZ] ÛÛÜXÈ [È ÌÎNÈØÈØHÛËYØ ÝÈ ][ÝÉ][ÝÈ [È ÌÍÝ[È [È ÌÎNÉ][ÝÉÌÎNË ÌÍØÚÝ^ÛYKÕ×ÒQJGood luck! [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Systems By Posted July 6, 2006 Author Share Posted July 6, 2006 Thanks for your help everyone. I'll try your suggestions and post back with the results. Link to comment Share on other sites More sharing options...
Skruge Posted July 6, 2006 Share Posted July 6, 2006 This:If Not FileExists($bckupextdirhome &$aRecords5) Then MsgBox(64, 'Info', 'File Does not exist')should be changed to this:If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist') [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Systems By Posted July 7, 2006 Author Share Posted July 7, 2006 This:should be changed to this:If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist')oÝ÷ Ûú®¢×¶¸vØb²X§zܡ׺Ú"µÍYÝ[Q^ÝÊ ÌÍØÚÝ^ÛYH [È ÌÍØTXÛÜÍVÉÌÍÞ WJH[ÙÐÞ ÌÎNÒ[ÉÌÎNË ÌÎNÑ[HÙÈÝ^Ý ÌÎNÊ and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas? Link to comment Share on other sites More sharing options...
Developers Jos Posted July 7, 2006 Developers Share Posted July 7, 2006 I tried this line of code If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist') and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas?Where do you make an array from the string variable &aRecords5 ? 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...
Skruge Posted July 7, 2006 Share Posted July 7, 2006 I tried this line of code ... and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas?Are there less than four files? That could cause you to go out of bounds. For $x5 = 1 to 4To move all files, use:For $x5 = 1 to $aRecords5[0]oÝ÷ Øò¢ê',ÛhÞºháø¥zˬzØb±«¢+Ù½ÈÀÌØíàÔôÄѼ}5¥¸ аÀÌØíI½ÉÌÕlÁt¤ [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] 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