2 Arrays in einem String oder einem Array?!

  • Hallo,

    Ich habe mir eine Website geschrieben, auf der Lieder zu einer Playlist hinzugefügt werden und danach gevoted werden können.
    Ich möchte später mit Autoit diese Datensätze weiterverarbeiten.

    Mein Problem:
    Ich habe 2 Arrays.

    [autoit]

    $interpret

    [/autoit]

    und

    [autoit]

    $titel

    [/autoit]

    Ich möchte jetzt in einem Array die Interpreten und den dazugehörigen Titel kombinieren, was später so aussehen soll:

    [autoit]

    $song[0] = $interpret[0] & $titel[0]
    $song[1] = $interpret[1] & $titel[1]
    ...

    [/autoit]

    Das ganze klappt leider nicht so ganz. Versucht habe ich es bis jetzt so:

    [autoit]

    $songs = ''

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

    For $r = 0 to UBound($interpret,1) -1
    $songs = $songs & @LF
    For $c = 0 to UBound($titel,1) - 1
    $songs = $songs & $interpret[$r] & $titel[$c] & " "
    Next
    Next

    [/autoit]

    Einmal editiert, zuletzt von MasterOfTime (18. September 2011 um 17:17)

  • Wie wäre es mit einem 2D Array? Wäre, finde ich, wesentlich praktischer. Dann könntest du in $aArray[n][0] Das Lied schreiben, in [n][1] den Interpreten, vllt auch Album und so weiter. Das wäre doch am übersichtlichsten oder nicht?

    Zu deinem Code:
    Ich würde
    1. Das

    [autoit]

    $song = $song & @LF

    [/autoit]


    nach der 2ten For Schleife setzen.

    Das Script würde ich so machen (Mit 2D Array)

    [autoit]

    #include <Array.au3>

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

    Dim $aLiedname[2]
    $aLiedname[0] = "Tears Don't Fall"
    $aLiedname[1] = "Junge"

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

    Dim $aInterpreten[2]
    $aInterpreten[0] = "Bullet for My Valentine"
    $aInterpreten[1] = "Die Ärzte"

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

    Dim $aSongs[UBound($aInterpreten)][2] ;; 2ten Index beliebg erweiterbar (mit Album, Länge etc)

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

    ;; [n][0] = Liedname
    ;; [n][1] = Interpret

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

    For $i = 0 To UBound($aSongs) - 1
    $aSongs[$i][0] = $aLiedname[$i]
    $aSongs[$i][1] = $aInterpreten[$i]
    Next

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

    _ArrayDisplay ($aSongs)

    [/autoit]