Jump to content

Getting values from textfile to list


tannerli
 Share

Recommended Posts

I've got a .txt file that I wrote with FileWriteLine

it looks like that:

\\pc001

\\pc002

\\pc003

etc...

now i want to import that list into a GUI-list that the different list items are choosable for the user...

i was trying to use guictrlsetdata but it doesn't work...

can someone help please

p.s sorry if my english's a bit strange, i'm german-speaking B)

Link to comment
Share on other sites

maybe like this

#include <GUIConstants.au3>

 

text_display("cell-list")



Func text_display( $text_info)
    
    Local $msg32, $msg32_box
    
    $Q_win = GUICreate("AutoitITS -  " & $text_info, 500, 250);, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_BORDER, $WS_CLIPSIBLINGS))
    $msg32_box = GUICtrlCreateList("", 0, 0, 500, 200); , 600 , 360 )
    GUICtrlSetFont(-1, 9, 500)
    $Qfile = FileOpen(@ScriptDir & "\" & $text_info & ".txt", 0)

; Check if file opened for reading OK
    If $Qfile = -1 Then
        MsgBox(0, "Error", "Unable to open file: " & $text_info &".txt   " )
        Exit
    EndIf

; Read in 1 character at a time until the EOF is reached
    While 3
        $Qchars = FileReadLine($Qfile)
        If @error = -1 Then ExitLoop
        GUICtrlSetData($msg32_box, $Qchars & @CRLF, 1)
    Wend

    FileClose($Qfile)
    
    $Button1 = GUICtrlCreateButton("&Select", 50, 210, 70, 20)
    
    
    GUISetState()     ;Show GUI

    While 4
        $msg32 = GUIGetMsg()
        Select
            Case $msg32 = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg32 = $Button1
                MsgBox(64,"Selection", (GUICtrlRead($msg32_box)))
        EndSelect
    WEnd
    GUIDelete($Q_win)
EndFunc  ;==>cell_terms

8)

NEWHeader1.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...