What Am I Doing Wrong?

  • This is the script I try to run:


    If i do this (the old way) it works pefrect but it only opens the same file every time:

    What im tryind to do is to load the filles 'C:\Users\joesoef pc\Desktop\autoit\programma\lijsten\lijsten2\variablemap\list1.txt'

    so when it starts up it doens't automaticly only opens :"C:\Users\joesoef pc\Desktop\autoit\programma\lijsten\list8.txt" like in the old script (above second script)

    so before it loads I go to $mFiles the $mFiles DOES shown all the file in the lijsten2 map then I click on map for example: map august, it says : Clicked = August

    just like you coded for me then it shows a message with the directory, but then it doesnt load the content I clicked.

    I realy dont know what I am doing wrong??

  • Zitat

    What Am I Doing Wrong?

    The "wrong" way is to produce lines and lines and lines and lines and lines of code doing copy & paste and edit....with all kinds of typos, logical faults and errors!

    And the worst kind of doing something wrong is crossposting! :thumbdown:
    Anyway...

    Global $iIndex = 0, $sListData4 = ($opgeslagen & $laden & $list4)
    Global $sListFile4 = ($opgeslagen & $laden & $list4)
    Global $iIndex = 0, $sListData5 = ($opgeslagen & $laden & $list5)
    Global $sListFile5 = ($opgeslagen & $laden & $list4)
    Global $iIndex = 0, $sListData6 = ($opgeslagen & $laden & $list6)
    Global $sListFile6 = ($opgeslagen & $laden & $list6)

    nothing to say...do you see what you are "doing wrong"?

    [autoit]

    $List1 = GUICtrlCreateList("", 0, 64, 145, 358)
    GUICtrlSetData(-1, "")
    $List2 = GUICtrlCreateList("", 144, 64, 65, 358)
    GUICtrlSetData(-1, "")

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

    ;some lines after..

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

    $list1 = ("\list1.txt")
    $list2 = ("\list2.txt")
    $list3 = ("\list3.txt")

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

    ;some lines after..

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

    GUICtrlSetData($List1, $sListData1)
    _GUICtrlListBox_SetCurSel($List1, $iIndex)

    [/autoit]


    You should take a look at the names of the variables...


    What you did in 40 lines can be done in 4 lines, using arrays. Example:

    [autoit]

    #include <GuiListBox.au3>
    #include <GUIConstantsEx.au3>

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

    For $i = 1 To 13
    FileDelete(@ScriptDir & "\list" & $i & ".txt")
    FileWrite(@ScriptDir & "\list" & $i & ".txt", "text " & $i)
    Next

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

    #Region ### START Koda GUI section ### Form=
    $Form1_1_1_1 = GUICreate("form", 814, 713, 697, 101)
    ;_GUIExtender_Init($Form1_1_1_1)

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

    Dim $listnr[11]
    Dim $list[15]
    Dim $sListFile[15]
    Dim $sListData[15]

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

    $Listnr[1] = GUICtrlCreateList("", 0, 64, 145, 358)
    GUICtrlSetData(-1, "")
    $Listnr[2] = GUICtrlCreateList("", 144, 64, 65, 358)
    GUICtrlSetData(-1, "")
    $Listnr[3] = GUICtrlCreateList("", 208, 64, 65, 358)
    GUICtrlSetData(-1, "")
    $Listnr[4] = GUICtrlCreateList("", 344, 64, 153, 358)
    GUICtrlSetData(-1, "")
    $Listnr[5] = GUICtrlCreateList("", 496, 64, 65, 358)
    GUICtrlSetData(-1, "")
    $Listnr[6] = GUICtrlCreateList("", 560, 64, 121, 230)
    GUICtrlSetData(-1, "")
    $Listnr[7] = GUICtrlCreateList("", 680, 64, 65, 230)
    GUICtrlSetData(-1, "")
    $Listnr[8] = GUICtrlCreateList("", 744, 64, 65, 230)
    GUICtrlSetData(-1, "")
    $Listnr[9] = GUICtrlCreateList("", 272, 64, 65, 358)
    GUICtrlSetData(-1, "")

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

    GUISetState(@SW_SHOW)

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

    ;~ $extand = GUICtrlCreateButton("extand", 504, 32, 65, 33)

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

    ;~ $iEdit_Section_Start = 30
    ;~ $iEdit_Section_Height = 250

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

    $iEdit_Section_Start = 30
    $iEdit_Section_Height = 210
    ;~ $iEdit_Section = _GUIExtender_Section_Start($Form1_1_1_1, $iEdit_Section_Start, $iEdit_Section_Height)
    ;~ _GUIExtender_Section_Action($Form1_1_1_1, $iEdit_Section)
    ;~ ; All control positions can then be related to the section start rather than the GUI <<<<<<<<<<<<<

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

    ;~ ; Now you can check that the _Section_Height is correct and amend if necessary <<<<<<<<<<<<<
    ;~ _GUIExtender_Section_End($Form1_1_1_1)
    ;~ _GUIExtender_Section_Extend($Form1_1_1_1, 0, False)

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

    $sPath = @ScriptDir ;@desktopdir & '\autoit\twitter programma\lijsten\lijsten2\'
    $hSearch = FileFindFirstFile($sPath & '*.*')

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

    Local $mFiles = GUICtrlCreateMenu('&File')

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

    Local $List_Start = GUICtrlCreateDummy() + 1
    While True
    $sFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sFile = ' & $sFile & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

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

    GUICtrlCreateMenuItem($sFile, $mFiles)
    WEnd
    Local $List_End = GUICtrlCreateDummy() - 1

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

    GUISetState()

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

    Local $iMSG
    While 1
    $iMSG = GUIGetMsg()
    Switch $iMSG
    Case $gui_event_close
    Exit
    Case $List_Start To $List_End
    ConsoleWrite('Clicked = ' & GUICtrlRead($iMSG, 1) & @CRLF)

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

    For $i = 1 To 13
    $list[$i] = ("\list" & $i & ".txt")
    Next

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

    $opgeslagen = @ScriptDir ;@desktopdir & 'C:\Users\joesoef pc\Desktop\autoit\programma\lijsten\lijsten2\'
    $laden = "" ;guictrlread($iMSG,1) & @CRLF

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

    MsgBox(1, "file:", "" & $opgeslagen & $laden & $list[1])

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

    Global $iIndex = 0
    For $i = 1 To 13
    $sListData[$i] = ($opgeslagen & $laden & $list[$i])
    $sListFile[$i] = ($opgeslagen & $laden & $list[$i])
    Next

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

    For $i = 1 To 10
    If FileExists($sListFile[$i]) Then
    $sListData[$i] = FileRead($sListFile[$i])
    GUICtrlSetData($Listnr[$i], $sListData[$i])
    _GUICtrlListBox_SetCurSel($Listnr[$i], $iIndex)
    EndIf
    Next

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

    EndSwitch
    WEnd

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

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    Einmal editiert, zuletzt von Andy (30. Oktober 2014 um 13:21)

  • Thank you Andy, It looks much better, but it stil doesnt open the .txt (note) somehow
    I just have a list1.txt file in this map:C:\Users\joesoef pc\Desktop\autoit\programma\lijsten\lijsten2\names1\list1.txt
    in this list1.txt I got

    Zitat

    eric|sara|brian|jo|selma|bruce1

    etc

    but it doesnt open the txt file with the names the,

    when I run this script
    and click the last file it shows me 4 maps (that i created) they al have a list1 to list9
    Im trying al day to figure this out but unsuccessful, please help me