reecedorward Posted August 11, 2012 Share Posted August 11, 2012 The idea is that I want to save user names to a text file.. then be able to recall or 'Load' users saved to that text file in a list.. I need the list to be displayed within the GUICtrlCreateList function.. Here is the code I'm having trouble with, it displays a list of arrays using _arraydisplay BUT I dont want it displayed in columns and rows... #include #include #include #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 277, 254, 192, 124) $write = GUICtrlCreateInput("", 16, 16, 161, 21) $enter = GUICtrlCreateButton("Enter", 192, 8, 73, 25) $names = GUICtrlCreateList("", 24, 56, 209, 175) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $userspath = "C:\Documents and Settings\matthews\My Documents\Reece's Scripts\Users.txt" $readusers = fileread($userspath) Local $array $read = _Filereadtoarray($userspath, $array) guictrlsetdata($names, $read) _arraydisplay($array) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $enter $readwrite = guictrlread($write) guictrlsetdata($names, $readwrite) guictrlsetdata($write, "") filewrite($userspath, $readwrite & @CRLF) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 11, 2012 Moderators Share Posted August 11, 2012 (edited) reecedorward,Take a look at this - should give you the idea: expandcollapse popup#include <GUIConstantsEx.au3> #include <File.au3> Global $userspath = "Users.txt" $Form1 = GUICreate("Form1", 277, 254, 192, 124) $write = GUICtrlCreateInput("", 16, 16, 161, 21) $enter = GUICtrlCreateButton("Enter", 192, 8, 73, 25) $names = GUICtrlCreateList("", 24, 56, 209, 175) GUISetState(@SW_SHOW) _Fill_List() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $enter ; Read the input $readwrite = GUICtrlRead($write) ; Add the name to the list GUICtrlSetData($names, $readwrite) GUICtrlSetData($write, "") ; Add the name to the file FileWriteLine($userspath, $readwrite) EndSwitch WEnd Func _Fill_List() ; Read the file into an array Local $array _FileReadToArray($userspath, $array) ; Check we read something If IsArray($array) Then ; Convert to a string with delimiters $sList = "" For $i = 1 To $array[0] $sList &= "|" & $array[$i] Next ; And fill the list GUICtrlSetData($names, $sList) EndIf EndFuncPlease ask if you have any questions. M23P.S. When you post code, please use Code tags - put [autoit] before and [/autoit] after your posted code. Edited August 11, 2012 by Melba23 Added PS Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now