Bert Posted 6 hours ago Posted 6 hours ago I have the following code: $i=1 $sIniFile = @ScriptDir & "\VQData\usernames.ini" local $sArrayUser = IniReadSectionNames($sIniFile) $Form1 = GUICreate("VollyQuizzer - Existing User", 413, 90, -1, -1) GUISetFont(12, 400, 0, "MS Sans Serif") $List1 = GUICtrlCreateList("", 24, 32, 200, 40) For $i = 1 To $sArrayUser[0] GUICtrlSetData($List1,$sArrayUser[$i]) Next $Label1 = GUICtrlCreateLabel("Select your name", 24, 8, 200, 24) $ButtonEU1 = GUICtrlCreateButton("Continue", 240, 32, 73, 25) $ButtonEU2 = GUICtrlCreateButton("Cancel", 325, 32, 73, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonEU1 ;goes to main screen $Readnameselected = GUICtrlRead($List1) If Stringlen($Readnameselected) = 0 then MsgBox(48, "Error", "You must either select an existing" & @cr _ & "user or create a new user.") EndIf If Stringlen($Readnameselected) <> 0 then $Quizusername = $Readnameselected GUIDelete() VQuizMain() EndIf Case $ButtonEU2 ;goes back to start screen GUIDelete() VStartup() EndSwitch WEnd When I run it, I see a list of names in the $List1 field. I want to have it show on default the field be empty and when the user clicks the up/down controls, it then will scroll to the first name. I tried to put in a dummy ini section name of [] but that didn't work. Tried [ ] too and that didn't work. In other words, when IniReadSectionNames creates the array, I need the first value in the array to be blank. Any suggestions? Logic says I need to add to the array an additional value of null. I tried _ArrayAdd and it didn't work either: $List1 = GUICtrlCreateList("", 24, 32, 200, 40) For $i = 1 To $sArrayUser[0] _ArrayAdd($sArrayUser," ") GUICtrlSetData($List1,$sArrayUser[$i]) Each time I run the script it returns the first name of the array as the default. In my case it is Arron Smith. It would not even add a text string such as "xxxxx". I read that _ArrayAdd() only adds to the end of an array so I'm a bit stumped. I've attached an ini file for testing. usernames.ini Second problem is the list is being shuffled in the array before updating the list control. I noticed the array is being sorted by the first letter. I suspect when it is doing the sort it is skipping any blanks. I'm OK with that, just as long as I can have the blank value be at the top of the array. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Solution Bert Posted 6 hours ago Author Solution Posted 6 hours ago (edited) Never mind. Got it. The solution is put in in the ini file, section header, this: [| |]. Pipes are the delimiter used in IniReadSectionNames. By putting in two pipes with a space between, you create a null value that will be at the top of the array list. Edited 6 hours ago by Bert more detailed explanation. argumentum 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/
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