Edit - automatisch Zeilen aus .ini laden

  • Also, ich hab eine Ini mit Folgendem Inhalt:

    Code
    [Quickchat]
    Line0=hallo
    Line1=alles klar?
    Line2=lroflmao

    Ich will Line0-2 automatisch laden lassen und habs mal so versucht:

    [autoit]

    $readqc = IniReadSection("config.ini","Quickchat")
    $string2 = ""
    Global $lines[Ubound($readqc, 1)]

    For $i = 0 To Ubound($readqc, 1)
    $string2 &= $readqc[$i][1]
    $lines[1] = $readqc[$i][1]
    Next
    GUICtrlSetData($Edit1,$string2)
    If _GUICtrlEdit_LineLength($Edit1) > 64 Then
    GUICtrlSetData($Edit1,"Too many characters")
    Else
    GUICtrlSetData($Edit1,$string2)
    EndIf

    [/autoit]

    $lines wurde natürlich als Array definiert:

    [autoit]

    Global $lines[1]

    [/autoit]

    Im Moment schließt sich die die GUI immer nach start... Syntax hat keine Fehler hervorgerufen...

  • Global $lines[Ubound($readqc, 1)]

    For $i = 0 To Ubound($readqc, 1)

    Da liegt der Fehler, $lines geht nur bis bis Ubound($readqc, 1)-1, weil es nullbasiert ist, deswegen Forschelife so:

    For $i = 0 To Ubound($readqc, 1)-1

  • versuch das so mal:

    For $i = 1 To $readqc[0][0]
    $string2 &= $readqc[$i][1]
    $lines[$i - 1] = $readqc[$i][1]
    Next


    BTW: Wo sind die Buttons hin für Spoiler und AutoIt und so?

  • TheShadowAE:
    Ah, verdammt da hätte ich auch selbst draufkommen können xD

    Ach ja, kleine Nebenfrage:
    Wie krieg ich jetzt jeden ini Eintrag in 1 Zeile?
    Wenn ich es so lasse, werden alle EInträge in eine Zeile, nur von einem Leerzeichen getrennt, geschrieben.

    EDIT:
    Ich habs jetzt hinbekommen, aber die erste Zeile is leer Oo

    [autoit]

    For $i = 0 To Ubound($readqc, 1) -1
    $string2 &= $readqc[$i][1] & @CRLF
    $lines[1] = $readqc[$i][1]
    Next

    [/autoit]
  • [autoit]


    $readqc = IniReadSection("config.ini","Quickchat")
    $string2 = ""
    Global $lines[Ubound($readqc, 1)]
    For $i = 0 To Ubound($readqc, 1)-1
    $lines[$i] = $readqc[$i][1]
    $string2&=$readqc[$i][1]&@crlf
    Next
    GUICtrlSetData($Edit1,$string2)
    If _GUICtrlEdit_LineLength($Edit1) > 64 Then
    GUICtrlSetData($Edit1,"Too many characters")
    Else
    GUICtrlSetData($Edit1,$string2)
    EndIf

    [/autoit]
  • Du hast nur 2 Zeilen vertauscht Oo
    Btw kann man

    [autoit]

    $lines[$i] = $readqc[$i][1]

    [/autoit]


    weglassen, hab ich eben gemerkt...

    Wenn man es so macht

    [autoit]

    $string2 &= @CRLF & $readqc[$i][1]

    [/autoit]


    sind die beiden ersten Zeilen frei, dafür aber nicht die letzte Oo

  • Suchst du das?:

    Spoiler anzeigen
    [autoit]

    $IniPath = @ScriptDir & "\Quickchat.ini"

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

    $Form1 = GUICreate("Form1", 363, 436, 617, 213)
    $Edit1 = GUICtrlCreateEdit("", 8, 8, 345, 337)
    GUICtrlSetFont(-1, 12)
    $Button1 = GUICtrlCreateButton("Button1", 96, 368, 177, 57)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $Button1
    _FillEdit($Edit1, $IniPath, "Quickchat")
    EndSwitch
    WEnd

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

    Func _FillEdit($hWnd, $sPath, $sSection)
    Local $sInput = ""
    $aRead = IniReadSection($sPath, $sSection)
    If @error Then SetError(1, 0, 0)
    If IsArray($aRead) Then
    For $i = 1 To Ubound($aRead) - 1
    If Not ($i = UBound($aRead) -1) Then
    $sInput &= ($aRead[$i][1]) & @CRLF
    Else
    $sInput &= ($aRead[$i][1])
    EndIf
    Next
    GUICtrlSetData($hWnd, $sInput & @CRLF)
    If @error Then SetError(2, 0, 0)
    EndIf
    Return 1
    EndFunc

    [/autoit]