Subscipt Variable in Case auslesen?

  • Hallo Leute,
    melde mich mal wieder zu meinem Projekt "Arduino Tools".
    Ich bin soweit, das man sich ein LCD-Char, über die weißen Kästchen, erstellen kann. Nun bin ich bei der automatischen Anpassung des Skriptes rechts daneben. Wird beispielsweise das erste Kästchen in der ersten Zeile geklickt, soll in dem Codefenster(erste Zeile nach"byte myChar[8] {") anstatt "B00000" "B10000" stehen.
    Ich hab schon so angefangen:

    [autoit]


    Case $aBitPics[1][1]
    MsgBox(0,"Test","Test")

    [/autoit]

    Das funzt nicht...
    Ich hab nen Kommentar ins Krisengebiet des Skriptes geschrieben(Zeile 136).
    Die Meldung(überhaupt die Aktion" funktioniert nicht...

    Weiß jemand wie ich das Problem beheben kann?

    Danke

    MfG button421

    Skript im Anhang!

  • Hallo Button421,

    dein ANsatz kann nicht funktionieren, da ich sehe dass du meinen

    Zitat

    Edit: Das Array aBit von 1 D auf 2 D umgestellt. Könnte im weiteren Projektverlauf nützlich sein.

    in deinem letzten Thema nicht beachtet hast hier noch einmal der Hinweis: dieser Voschlag baut auf dem 2D Array auf. Hier das Skript:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #include <ListViewConstants.au3>
    ;----------------------------------HOME-------------------------------------------------------
    $hFrmHome = GUICreate("Arduino Tools 1.2", 627, 443, 192, 124)
    ;$background =
    GUICtrlCreatePic(@ScriptDir & "\Images\computer_0014.jpg", 0, 0, 625, 441, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    ;$was =
    GUICtrlCreateLabel("Was möchten sie tun?", 176, 24, 257, 33, $SS_SUNKEN)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x00FF00)
    $idBtnComandRef = GUICtrlCreateButton("&Befehlsreferenz", 8, 136, 249, 41, $WS_GROUP)
    GUICtrlSetTip(-1, "Zeigt eine Referenz aller Grundbefehle an")
    $idBtnShowCharCreator = GUICtrlCreateButton("LCD-Charakter-&Creator", 10, 191, 249, 41, $WS_GROUP)
    GUICtrlSetTip(-1, "Damit können sie einen LCD-Charakter selbst erstellen")
    $idBtnArduinoHP = GUICtrlCreateButton("Arduino-&Homepage", 8, 248, 249, 41, $WS_GROUP)
    GUICtrlSetTip(-1, "Blättern sie in vielen Schaltungsbildern!")
    $idBtnInfoHelp = GUICtrlCreateButton("&Info/ Hilfe", 8, 384, 177, 49, $WS_GROUP)
    $idBtnExit = GUICtrlCreateButton("Be&enden", 400, 384, 217, 49, $WS_GROUP)
    GUISetState(@SW_SHOW)
    ;----------------------------------------------------------------------------------------------
    ;--------------------------------BEFEHLSREFERENZ-----------------------------------------------
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #region ### START Koda GUI section ### Form=
    $hFrmComandRef = GUICreate("Arduino Tools - Befehlsreferenz", 627, 444, 192, 124)
    ;$background =
    GUICtrlCreatePic(@ScriptDir & "\Images\computer_0014.jpg", 0, 0, 625, 441, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    ;$das1 =
    GUICtrlCreateLabel("Befehlsreferenz", 216, 24, 188, 33, $SS_SUNKEN)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x00FF00)
    $idLVComannds = GUICtrlCreateListView("Befehl", 8, 64, 241, 369)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 237)
    Global $idLVItemComand[15]
    $idLvItemComand[0] = GUICtrlCreateListViewItem("int", $idLVComannds)
    $idLvItemComand[1] = GUICtrlCreateListViewItem("LiquidCrystal", $idLVComannds)
    $idLvItemComand[2] = GUICtrlCreateListViewItem("void setup()", $idLVComannds)
    $idLvItemComand[3] = GUICtrlCreateListViewItem("void loop()", $idLVComannds)
    $idLvItemComand[4] = GUICtrlCreateListViewItem("tone", $idLVComannds)
    $idLvItemComand[5] = GUICtrlCreateListViewItem("lcd.begin()", $idLVComannds)
    $idLvItemComand[6] = GUICtrlCreateListViewItem("lcd.setCursor()", $idLVComannds)
    $idLvItemComand[7] = GUICtrlCreateListViewItem("lcd.print()", $idLVComannds)
    $idLvItemComand[8] = GUICtrlCreateListViewItem("lcd.noBlink()", $idLVComannds)
    $idLvItemComand[9] = GUICtrlCreateListViewItem("lcd.noCursor", $idLVComannds)
    $idLvItemComand[10] = GUICtrlCreateListViewItem("digitalWrite()", $idLVComannds)
    $idLvItemComand[11] = GUICtrlCreateListViewItem("delay()", $idLVComannds)
    $idLvItemComand[12] = GUICtrlCreateListViewItem("pinMode()", $idLVComannds)
    $idLvItemComand[13] = GUICtrlCreateListViewItem("Serial.begin()", $idLVComannds)
    $idLvItemComand[14] = GUICtrlCreateListViewItem("Serial.print()", $idLVComannds)
    $idEdtReference = GUICtrlCreateEdit("", 280, 64, 337, 369)
    GUICtrlSetData(-1, "<---- Bitte links Befehl auswählen!")
    $idBtnBackToHomeFromCCFromCF = GUICtrlCreateButton("&Zurück", 536, 0, 89, 25, $WS_GROUP)
    GUISetState(@SW_HIDE)
    #endregion ### END Koda GUI section ###
    ;----------------------------------------------------------------------------------------------
    ;-------------------------------LCD-CHARAKTER-CREATOR------------------------------------------
    $hFrmCharCreator = GUICreate("Arduino Tools - LCD-Charakter-Creator", 627, 442, 192, 124)
    ;$background =
    GUICtrlCreatePic(@ScriptDir & "\Images\computer_0014.jpg", 0, 0, 625, 441, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    ;$das2 =
    GUICtrlCreateLabel("LCD-Charakter-Creator", 176, 16, 272, 33, $SS_SUNKEN)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0x00FF00)
    Global $aBit[5][8]
    Global $aBitPics[5][8]
    for $i = 0 to 4
    for $j = 0 to 7
    $aBitPics[$i][$j] = GUICtrlCreatePic(@ScriptDir & "\Images\lcddeactiv.bmp", 16+ $i*38, 80+$j*40, 33, 33)
    Next
    Next
    $idBtnBackToHomeFromCC = GUICtrlCreateButton("&Zurück", 536, 0, 89, 25, $WS_GROUP)
    $idEdtScript = GUICtrlCreateEdit("", 304, 80, 313, 353, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
    GUICtrlSetData(-1, StringFormat("#include <LiquidCrystal.h>\r\n\r\nLiquidCrystal lcd(12,11,10,5,4,3,2);\r\n\r\nbyte myChar[8] =\r\n{\r\n B00000,\r\n B00000,\r\n B00000,\r\n B00000,\r\n B00000,\r\n B00000,\r\n B00000,\r\n B00000\r\n};\r\n\r\nvoid setup()\r\n{\r\n lcd.createChar(0, myChar);\r\n lcd.begin(16,2);\r\n lcd.write(0);\r\n}\r\n\r\nvoid loop() {}"))
    GUISetState(@SW_HIDE)
    ;----------------------------------------------------------------------------------------------
    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1] ;von welchem Fnster kommt die Message?
    Case $hFrmHome ;Message des Hauptfensters
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE, $idBtnExit
    Exit
    Case $idBtnShowCharCreator
    GUISetState(@SW_SHOW, $hFrmCharCreator)
    GUISetState(@SW_DISABLE, $hFrmHome)
    Case $idBtnComandRef
    GUISetState(@SW_SHOW, $hFrmComandRef)
    GUISetState(@SW_DISABLE, $hFrmHome)
    Case $idBtnArduinoHP
    ShellExecute("http://arduino.cc/")
    Case $idBtnInfoHelp
    MsgBox(64, "Info/Hilfe", "Zuerst wählen sie ein Menüpunkt aus! Klicken sie auf ""Befehlsreferenz"" um eine vollständige Referenz für alle Grundbefehle zu erhalten! Klicken sie auf ""LCD-Charakter-Creator"", um einen eigenen LCD-Charakter zu erstellen. Der Quellcode wird rechts angezeigt." & @CRLF & "" & @CRLF & "created by button421 on autoit.de!")
    EndSwitch
    Case $hFrmComandRef
    Switch $nMsg[0]
    Case $idBtnBackToHomeFromCCFromCF, $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $hFrmComandRef)
    GUISetState(@SW_ENABLE, $hFrmHome)
    WinActivate($hFrmHome)
    EndSwitch
    Case $hFrmCharCreator
    Switch $nMsg[0]
    Case $idBtnBackToHomeFromCC, $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $hFrmCharCreator)
    GUISetState(@SW_ENABLE, $hFrmHome)
    WinActivate($hFrmHome)
    Case $aBitPics[0][0] to $aBitPics[4][7]
    $id = $nMsg[0]-$aBitPics[0][0]
    $iRow = int($id/8)
    $iCol = mod($id,8)
    if $aBit[$iRow][$iCol] Then
    GUICtrlSetImage($aBitPics[$iRow][$iCol],@ScriptDir & "\Images\lcddeactiv.bmp")
    Else
    GUICtrlSetImage($aBitPics[$iRow][$iCol],@ScriptDir & "\Images\lcdactiv.bmp")
    EndIf
    $aBit[$iRow][$iCol] = not $aBit[$iRow][$iCol]
    _createC()
    EndSwitch
    EndSwitch
    WEnd

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

    Func _createC()
    Local $sB_Line
    Local $sC = "#include <LiquidCrystal.h>" & @CRLF & @CRLF & "LiquidCrystal lcd(12,11,10,5,4,3,2);" & @CRLF & @crlf & "byte myChar[8] =" & @crlf & "{" & @CRLF
    Local $sC_End = "};" & @CRLF & @CRLF & "void setup()" & @CRLF & "{" & @CRLF & " lcd.createChar(0, myChar);" & @CRLF & " lcd.begin(16,2);" & @CRLF & " lcd.write(0);" & @CRLF & "}" & @CRLF & @CRLF & "void loop() {}"
    for $i = 0 to 7
    $sB_Line = " B"
    for $j = 0 to 4
    if $aBit[$j][$i] Then
    $sB_Line &= "1"
    Else
    $sB_Line &= "0"
    EndIf
    Next
    $sC &= $sB_Line & @CRLF
    Next
    $sC &= $sC_End
    GUICtrlSetData($idEdtScript,$sC)
    EndFunc

    [/autoit]

    Es ist eigentich nur die _createC() dazugekommen die bei jedem Klick auf eines der BIT-Bilder aufgerufen wird.

    mfg autoBert