Jump to content

Help debugging variable bug


BALA
 Share

Recommended Posts

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-LETED", 240, 170)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

GUICtrlCreateLabel("Type in the path of the directory you want to scan and press 'BA-LETE' to start scanning.", 10, 10, 220, 40)

$input = GUICtrlCreateInput("C:\",30, 50, 180, 20)

$cookie = GUICtrlCreateCheckbox ("Delete files in the 'Cookies' Folder", 10, 80, 180, 20)

;Defined it here?
$Histroy = GUICtrlCreateCheckbox ("Delete files in the 'History' Folder", 10, 100, 180, 20)

$begin = GUICtrlCreateButton("BA-LETE", 60, 130, 120)
GUICtrlSetOnEvent($begin, "Begin")

Dim $FileCount = 0
Dim $FileCountDel = 0

Func CLOSEClicked()
    Exit
EndFunc

Func Begin()
    If GUICtrlRead($cookie) = $GUI_CHECKED Then
        Dim $CookieFolder = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Cookies")
        ScanFolder2($CookieFolder)
    EndIf
    
    If GUICtrlRead($History) = $GUI_CHECKED Then
        Dim $HistoryFolder = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","History")
        ScanFolder2($HistoryFolder)
    EndIf
    
    Dim $FolderName = GUICtrlRead($input)
    
    ScanFolder($FolderName)
    
    MsgBox(0,"Done","Folder Scan Complete.  Scanned " & $FileCount & "Files.  BA-LETED " & $FileCountDel & " Files")

    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","")
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","You scanned " & $FileCount & " Files")
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt","You BA-LETED " & $FileCountDel & " Files!")
EndFunc

Func ScanFolder2($SourceFolder)
    Local $Search
    Local $File
    Local $FileAttributes
    Local $FullFilePath

    $Search = FileFindFirstFile($SourceFolder & "\*.*")
 
    While 1
        If $Search = -1 Then
            ExitLoop
        EndIf

        $File = FileFindNextFile($Search)
        If @error Then ExitLoop

        $FullFilePath = $SourceFolder & "\" & $File
        $FileAttributes = FileGetAttrib($FullFilePath)

        If StringInStr($FileAttributes,"D") Then
            ScanFolder($FullFilePath)
        Else
            ToolTip($FullFilePath,0,0)
            $FileCount += 1
        EndIf
        
        FileDelete($FullFilePath)
        LogFile($FullFilePath)
    WEnd
 
    FileClose($Search)
EndFunc

Func ScanFolder($SourceFolder)
    Local $Search
    Local $File
    Local $FileAttributes
    Local $FullFilePath

    $Search = FileFindFirstFile($SourceFolder & "\*.*")
 
    While 1
        If $Search = -1 Then
            ExitLoop
        EndIf

        $File = FileFindNextFile($Search)
        If @error Then ExitLoop

        $FullFilePath = $SourceFolder & "\" & $File
        $FileAttributes = FileGetAttrib($FullFilePath)

        If StringInStr($FileAttributes,"D") Then
            ScanFolder($FullFilePath)
        Else
            ToolTip($FullFilePath,0,0)
            $FileCount += 1
        EndIf
        If StringInStr($FileAttributes,"T") Then
            FileDelete($FullFilePath)
            LogFile($FullFilePath)
        EndIf
 
    WEnd
 
    FileClose($Search)
EndFunc
 
Func LogFile($FileName)
    FileWriteLine(@ScriptDir & "\BA-LETION_Log.txt",$FileName)
    $FileCountDel += 1
EndFunc

While 1
    sleep(10)
WEnd

When I try to run the program, it says that $History is being used without being defined, but didn't I already define it?

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...