Jump to content

Little problem with arrays and checkboxes.


 Share

Recommended Posts

I want to make a script for changing the names of all the files in a directory. Here's what I've done:

#include <File.au3>
#include <Constants.au3>
#include <Guiconstants.au3>

Opt("GUIOnEventMode",1)
$lista1=_FileListToArray(@ScriptDir,"*.*")
$altolista=(25 * $lista1[0])
$altoventana=$altolista+20
If $altoventana > @DesktopHeight Then
    MsgBox(0,"","Demasiados archivos en el directorio!")
    Exit
EndIf

GUICreate("",300,$altoventana)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUISetState()
GUICtrlCreateButton("Cambiar nombre",125,$altoventana-35)
GUICtrlSetOnEvent(-1,"cambiar_nombre")

obtenerArchivos()

Func _exit()
    Exit
EndFunc

Func obtenerArchivos()
$iCheckboxPos = 15
    Global $aCheckbox[UBound($lista1) ]
    For $i = 1 To $lista1[0] Step 1
        $aCheckbox[$i] = GUICtrlCreateCheckbox($lista1[$i], 10, $iCheckboxPos, -1, 20)
        GUICtrlSetState(-1, $GUI_CHECKED)
        $iCheckboxPos = $iCheckboxPos + 20
        $aCheckbox[0] = UBound($aCheckbox)
    Next
EndFunc
Func cambiar_nombre()
    For $i = 1 To (UBound($aCheckbox)-1)
        $sActiveCheckbox = $aCheckbox[$i]
        If GUICtrlRead($sActiveCheckbox) = $GUI_CHECKED Then
            MsgBox(0,"",GUICtrlRead($aCheckbox[$i]))
            GUICtrlSetState($sActiveCheckbox, $GUI_UNCHECKED)
        EndIf
    Next
EndFunc


While 1
    Sleep(100)
WEnd

This won't change the names of any files, because I didn't finish it. My problem is that I can't get it to read the names of the files that are checked! It always returns 1 :)

Edited by Nahuel
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...