+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, AutoIT help. in Coding and Web Development; I've just managed to break a script I'm working on and I can't work out why. Code: #include <file.au3> Dim ...
  1. #1


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 434 Times in 353 Posts
    Rep Power
    125

    AutoIT help.

    I've just managed to break a script I'm working on and I can't work out why.

    Code:
    #include <file.au3>
    Dim $aRecords
    Dim $DirLoc
    _FileReadToArray("list.txt",$aRecords)
    
    
    For $x = 1 to $aRecords[0]
    
    	$DirLoc = "C:\Documents and Settings\" & $aRecords[$x]
    	
    	
    	If FileExists($DirLoc) Then
    		DirRemove ($DirLoc ,1)
    	
    
    NEXT
    The error is "Next" statement with no matching "For" statement.

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318

    Re: AutoIT help.

    Missing EndIf?

  3. #3

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,691
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731

    Re: AutoIT help.

    If its not that it might be the {} brackets around the loop contents, if the syntax is like C

  4. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,691
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731

    Re: AutoIT help.

    Possibly as below
    Code:
    #include <file.au3>
    Dim $aRecords
    Dim $DirLoc
    _FileReadToArray("list.txt",$aRecords)
    
    
    FOR $x = 1 to $aRecords[0]{
    	$DirLoc = "C:\Documents and Settings\" & $aRecords[$x]
    	
    	
    	If FileExists($DirLoc) Then
    		DirRemove ($DirLoc ,1)
            }
    NEXT
    Otherwise I think it will only loop the first line.

  5. #5

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318

    Re: AutoIT help.


  6. #6


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 434 Times in 353 Posts
    Rep Power
    125

    Re: AutoIT help.

    Cheers webman, Endif sorts it. Or placing the line that starts DirRemove on the same line as the if.

    I'm going to have to change it anyway. I'm getting errors if there are blank lines in my text file.

  7. #7

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318

    Re: AutoIT help.

    Cool

    For the blank line problem, I would do.... in the loop, a Stringlen() check against $aRecords[$x]; and only do FileExists() if len is greater than 1? But saying that, the DirExists() function should catch any problematic directories :?

  8. #8


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 434 Times in 353 Posts
    Rep Power
    125

    Re: AutoIT help.

    What's happening is if there is a blank line it trys to delete c:\documents and settings. Luckily Autoit has a fail safe.

    At the moment I'm up to
    Code:
    #include <file.au3>
    Dim $aRecords
    Dim $DirLoc
    _FileReadToArray("list.txt",$aRecords)
    
    
    For $x = 1 to $aRecords[0]
    
    
    	$DirLoc = "C:\Documents and Settings\" & $aRecords[$x]
    	
    	If $aRecords[$x] = True then
    		If FileExists($DirLoc) Then 
    		DirRemove ($DirLoc ,1)
    		EndIf
    	EndIf
    	
    
    
    Next

SHARE:
+ Post New Thread

Similar Threads

  1. software via autoit in AD
    By chrbb in forum Windows
    Replies: 6
    Last Post: 14th November 2007, 08:15 AM
  2. AutoIT help
    By randle in forum Windows
    Replies: 14
    Last Post: 11th July 2007, 09:26 AM
  3. AutoIT
    By Gatt in forum Scripts
    Replies: 3
    Last Post: 3rd July 2007, 01:29 PM
  4. AutoIT process communication
    By NetworkGeezer in forum Scripts
    Replies: 2
    Last Post: 9th May 2007, 08:00 PM
  5. Install software using AutoIT??
    By SpuffMonkey in forum How do you do....it?
    Replies: 3
    Last Post: 21st March 2007, 01:50 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •