Problem mit Arrays

  • Huhu,
    Ich habe folgendes Problem:
    Ich möchte mir einen kleinen Musicplayer selber schreiben so als Übung nur hab ich jetzt ein Problem mit den Arrays X( im Verzeichnis des Players sind unter \Music\ 13 Liederordner davon sind in 4 auch schon Lieder. Die Ordner werden allesammt links in einem Combo mit der Hauptüberschrift Interpret angezeigt. Daneben ist eine weiter Combo mit dem Namen Song. Eigentlich sollte wenn man einen der Interpreten auswählt rechts alle Songs die in dem Ordner des Interpreten sind erscheinen nur das tuen sie nicht :( das Combo Songs bleibt immer leer egal welchen Interpret man auswählt =/ hab schon ewig lange rumprobiert aber es funktioniert einfach nicht X(

    Mfg Bloodykill aka Sevenby7 :/


    Spoiler anzeigen
    [autoit]

    $Interpret_Read=0
    $Interpret=_FileListToArray("C:\Users\Bastian\Desktop\Sevenby7 Musicplayer\Music","*",2)
    $A_max1=_ArrayMax($Interpret)
    $Anz1=0
    $A_Anz1=0
    #include <GUIConstantsEx.au3>
    #include <ComboConstants.au3>
    #Include <File.au3>
    #include <Array.au3>
    Opt("GUIOnEventMode", 1)
    GUICreate("Media Player V 1.0.0 Betha",400,400)
    GUICtrlCreateTab(1,1,399,30)
    GUICtrlCreateGroup("",300,31,99,367)
    GUICtrlCreateTabItem("Player")
    GUICtrlCreateButton("Play",305,43,89,44)
    $Combo_Interpret=GUICtrlCreateCombo("Interpret",1,31,99,999,$CBS_OEMCONVERT)
    $Combo_Song=Guictrlcreatecombo("Song",100,31,99,319)
    GUICtrlCreateTabItem("Options")
    $Aktualisieren=GUICtrlCreateButton("Aktualisieren",1,31,99,39)
    GUICtrlSetOnEvent($Aktualisieren,"_aktualisieren")
    $Player_Close=GUICtrlCreateButton("Player Schließen",100,31,99,39)
    GUICtrlSetOnEvent($Player_Close,"_exit")
    Guisetonevent(-3,"_exit")
    _CreateInterpret()
    GUISetState()
    Func _CreateInterpret()
    $Interpret=_FileListToArray("C:\Users\Bastian\Desktop\Sevenby7 Musicplayer\Music","*",2)
    $A_max1=_ArrayMax($Interpret)
    $A_Anz1=1
    While $A_Anz1<=$A_max1
    GUICtrlSetData($Combo_Interpret,$Interpret[$A_Anz1])
    $A_Anz1=$A_Anz1+1
    WEnd
    $A_Anz1=1
    EndFunc
    While 1
    $Interpret_Read=GUICtrlRead($Combo_Interpret) ;Liest aus welcher Interpret ausgewählt wurde
    $A_max1=_ArrayMax($Interpret) ;Gibt die Anzahl der Interpreten zurück
    While $A_Anz1<=$A_max1 ;Wiederhohlt schleife A solange die Schleifenzahl($A_Anz1)<=der Interpretenzahl($A_max1) ist.
    If $Interpret_Read=$Interpret[$A_Anz1] Then ;Frägt ab ob der ausgewählte Interpretenname($Interpret_Read) in einem Array der Interpretenliste($Interpret[$A_Anz1]) enthallten ist.
    $Songs=_FileListToArray("C:\Users\Bastian\Desktop\Sevenby7 Musicplayer\Music\"&$Interpret_Read,"*",1) ;Erställt ein Array als Songlist($Songs) welches den Namen aller Lieder im Ordner Music+Interpretennamen wiedergebt
    $A_max2=_ArrayMax($Songs)
    $A_Anz1=1
    While $A_Anz1<=$A_max2
    GUICtrlSetData($Combo_Song,$Songs[$A_Anz1])
    $A_Anz1=$Anz1+1
    WEnd
    EndIf
    $A_Anz1=$Anz1+1
    WEnd
    WEnd
    Func _aktualisieren()
    EndFunc
    Func _exit()
    Exit
    EndFunc

    [/autoit]

    2 Mal editiert, zuletzt von Bloodykill (16. August 2010 um 19:58)

  • Hallo BloodyKill in Zeile 41 fehlt auf jedenfal ein BackSlash, sollte so aussehen:

    [autoit]

    $Songs=_FileListToArray("C:\Users\Bastian\Desktop\Sevenby7 Musicplayer\Music\" & "\" & $Interpret_Read,"*",1) ;Erställt ein Array als Songlist($Songs) welches den Namen aller Lieder im Ordner Music+Interpretennamen wiedergebt

    [/autoit]

    desweiteren solltest du die Routine zum Befüllen der $combo_Song auf ein Svent legen und nicht in der While-Wend Schleife anarbeiten,

    mfg (auto)Bert

  • Das wirkt alles so verkompliziert. Auch die Verwendung von _ArrayMax() will mir nicht ganz einleuchten.

    &quot;mal auf die Schnelle&quot;
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ComboConstants.au3>
    #include <File.au3>
    #include <Array.au3>
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $dir = @UserProfileDir & "\Music" ;Pfad anpassen

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("Media Player V 1.0.0 Betha", 400, 400)
    GUICtrlCreateTab(1, 1, 399, 30)
    GUICtrlCreateGroup("", 300, 31, 99, 367)
    GUICtrlCreateTabItem("Player")
    GUICtrlCreateButton("Play", 305, 43, 89, 44)
    $Combo_Interpret = GUICtrlCreateCombo("", 1, 31, 99, 999, $CBS_OEMCONVERT)
    GUICtrlSetOnEvent(-1, "_createSonglist")
    $Combo_Song = GUICtrlCreateCombo("Song", 100, 31, 99, 319)
    GUICtrlCreateTabItem("Options")
    $Aktualisieren = GUICtrlCreateButton("Aktualisieren", 1, 31, 99, 39)
    GUICtrlSetOnEvent($Aktualisieren, "_aktualisieren")
    $Player_Close = GUICtrlCreateButton("Player Schließen", 100, 31, 99, 39)
    GUICtrlSetOnEvent($Player_Close, "_exit")
    GUISetOnEvent(-3, "_exit")
    _CreateInterpret()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _createSonglist()
    $aSongs = _FileListToArray($dir & "\" & GUICtrlRead($Combo_Interpret), "*.mp3", 1)
    For $i = 1 To $aSongs[0]
    GUICtrlSetData($Combo_Song, $aSongs[$i])
    Next
    EndFunc ;==>_createSonglist

    [/autoit] [autoit][/autoit] [autoit]

    Func _CreateInterpret()
    $Interpret = _FileListToArray($dir, "*", 2)
    For $i = 1 To $Interpret[0]
    GUICtrlSetData($Combo_Interpret, $Interpret[$i])
    Next
    EndFunc ;==>_CreateInterpret

    [/autoit] [autoit][/autoit] [autoit]

    Func _aktualisieren()
    EndFunc ;==>_aktualisieren

    [/autoit] [autoit][/autoit] [autoit]

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]
  • _ArrayMax() hab ich verwendet, da ein Fehler auftritt wenn z.B. Array 14 aufgerufen wird und es aber nur 13 Lieder gibt. Also als sone art Sperre *gg* ich probier mal deins

  • Hallo BloodyKill,

    wie Schnitzel schon anmerkte es muss natürlich Rvent heissen, das kannst du mit GuiCtrlSetOnEvent machem. Mein Lösungsvorschlag sieht damit so aus:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ComboConstants.au3>
    #include <File.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    $Mp3MainPath = "C:\Programme\AutoIt3\MyProjects\MP3_Batchdownloader\Downloaded"

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("Media Player V 1.0.0 Betha", 400, 400)
    GUICtrlCreateTab(1, 1, 399, 30)
    GUICtrlCreateGroup("", 300, 31, 99, 367)
    GUICtrlCreateTabItem("Player")
    GUICtrlCreateButton("Play", 305, 43, 89, 44)
    $Combo_Interpret = GUICtrlCreateCombo("Interpret", 1, 31, 99, 999, $CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1, "Songs")
    $Combo_Song = GUICtrlCreateCombo("Song", 100, 31, 99, 319)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateTabItem("Options")
    $Aktualisieren = GUICtrlCreateButton("Aktualisieren", 1, 31, 99, 39)
    GUICtrlSetOnEvent($Aktualisieren, "_aktualisieren")
    $Player_Close = GUICtrlCreateButton("Player Schließen", 100, 31, 99, 39)
    GUICtrlSetOnEvent($Player_Close, "_exit")
    GUISetOnEvent(-3, "_exit")
    _CreateInterpret()
    Songs()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Songs()
    $Interpret_Read = GUICtrlRead($Combo_Interpret) ;Liest aus welcher Interpret ausgewählt wurde
    ConsoleWrite($Interpret_Read & @CRLF)
    $Songs = _FileListToArray($Mp3MainPath & "\" & $Interpret_Read, "*", 1) ;Erställt ein Array als Songlist($Songs) welches den Namen aller Lieder im Ordner Music+Interpretennamen wiedergebt
    If IsArray($Songs) Then
    GUICtrlSetData($Combo_Song, "", "")
    For $A_Anz1 = 1 To UBound($Songs) - 1
    GUICtrlSetData($Combo_Song, $Songs[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Song, $Songs[1], $Songs[1])
    EndIf
    EndFunc ;==>Songs

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateInterpret()
    $Interpret = _FileListToArray($Mp3MainPath, "*", 2)
    If IsArray($Interpret) Then
    GUICtrlSetData($Combo_Interpret, "", "")
    For $A_Anz1 = 1 To UBound($Interpret) - 1
    GUICtrlSetData($Combo_Interpret, $Interpret[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Interpret, $Interpret[1], $Interpret[1])
    EndIf
    EndFunc ;==>_CreateInterpret

    [/autoit] [autoit][/autoit] [autoit]

    Func _aktualisieren()
    EndFunc ;==>_aktualisieren

    [/autoit] [autoit][/autoit] [autoit]

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]

    mfg (auto)Bert


  • :party: Genial danke dir