Trinnon Posted October 25 Share Posted October 25 I have run into another issue with my project... Not sure if this should be in this GUI area of the forum or another. I am trying to get the items that are selected to create a file for each selection. I can output a single selection to a file without issue. I think I need some array to loop through each selection to create the files but I really do not understand arrays. I tried looking through the array tutorial but it is over my head. Most of the things I create are simple and do not require any array. Any assistance is welcomed. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListBox.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=\\bjcsccmfr01\osd.files\_prodtsfiles\osdfrontend-v2\optionlistformtest.kxf $Form1_1 = GUICreate("OptionListForm", 627, 437, 324, 124) $List1 = GUICtrlCreateList("", 48, 120, 217, 266,BitOr($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL)) $List2 = GUICtrlCreateList("", 360, 120, 217, 266) $Option1rdo = GUICtrlCreateRadio("Option 1", 48, 24, 73, 25) $Option2rdo = GUICtrlCreateRadio("Option 2", 48, 56, 73, 25) $add = GUICtrlCreateButton("add", 280, 168, 65, 33) $clear = GUICtrlCreateButton("clear", 280, 216, 65, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $VariableFiles = "Y:\VariableFiles" DirCreate($VariableFiles) GLOBAL $sOptionList = @ScriptDir & "\OptionList.txt" GLOBAL $sOptionList2 = @ScriptDir & "\OptionList2.txt" Global $aList Global $sList While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Option1rdo GUICtrlSetData($List1, "") GUICtrlSetData($List2, "") _FileReadToArray($sOptionList, $aList, $FRTA_NOCOUNT) $sList = _ArrayToString($aList, "|") GUICtrlSetData($List1, $sList, "") FileOpen($VariableFiles & "Option1", 1) Case $Option2rdo GUICtrlSetData($List1, "") GUICtrlSetData($List2, "") _FileReadToArray($sOptionList2, $aList, $FRTA_NOCOUNT) $sList = _ArrayToString($aList, "|") GUICtrlSetData($List1, $sList, "") FileOpen($VariableFiles & "Option2", 1) Case $add _AddList() Case $clear GUICtrlSetData($List2, "", "") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _AddList() Local $aList = _GUICtrlListBox_GetSelItemsText($List1) Local $sList = _ArrayToString($aList, "|", 1, -1) GUICtrlSetData($List2, $sList, "") If IsArray($sList) Then For $i = 0 to $sList[0] MsgBox($MB_SYSTEMMODAL, "Array Info", "Array Text: " & _GUICtrlListBox_GetText($sList[$i],1)) FileOpen($VariableFiles & $sList[$i],1) Next EndIf ;These work for a single selection only.... ;FileOpen($VariableFiles & $sList,1) ;MsgBox($MB_SYSTEMMODAL, "Information", "Item Text: " & $sList,1) EndFunc Thanks Trinnon Link to comment Share on other sites More sharing options...
Solution Nine Posted October 25 Solution Share Posted October 25 I think your problem is that you are using $sList as an array while it should be $aList. ps. it is hard to help when you do not provide a full runable snippet of your code (aka OptionList.txt files). And you did not clarify what this code is supposed to do... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Trinnon Posted October 25 Author Share Posted October 25 Wow. I cannot believe I was that close to it working. I never tried $alist. The only thing it does that I don't need is it creates a file with the number of items selected. I can just ignore that file. The optionlists are just text files with random words in one column. I want to leave file names as breadcrumbs for another process to pick them up and make them variables inside an SCCM Task Sequence to install applications and set regisry tatoos. This is just my simple sample version of the code used to troubleshoot specific issues. Here is the updated code and the optionlist files. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListBox.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=\\bjcsccmfr01\osd.files\_prodtsfiles\osdfrontend-v2\optionlistformtest.kxf $Form1_1 = GUICreate("OptionListForm", 627, 437, 324, 124) $List1 = GUICtrlCreateList("", 48, 120, 217, 266,BitOr($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL)) $List2 = GUICtrlCreateList("", 360, 120, 217, 266) $Option1rdo = GUICtrlCreateRadio("Option 1", 48, 24, 73, 25) $Option2rdo = GUICtrlCreateRadio("Option 2", 48, 56, 73, 25) $add = GUICtrlCreateButton("add", 280, 168, 65, 33) $clear = GUICtrlCreateButton("clear", 280, 216, 65, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $VariableFiles = "Y:\VariableFiles" DirCreate($VariableFiles) GLOBAL $sOptionList = @ScriptDir & "\OptionList.txt" GLOBAL $sOptionList2 = @ScriptDir & "\OptionList2.txt" Global $aList Global $sList While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Option1rdo GUICtrlSetData($List1, "") GUICtrlSetData($List2, "") _FileReadToArray($sOptionList, $aList, $FRTA_NOCOUNT) $sList = _ArrayToString($aList, "|") GUICtrlSetData($List1, $sList, "") FileOpen($VariableFiles & "\Option1", 1) Case $Option2rdo GUICtrlSetData($List1, "") GUICtrlSetData($List2, "") _FileReadToArray($sOptionList2, $aList, $FRTA_NOCOUNT) $sList = _ArrayToString($aList, "|") GUICtrlSetData($List1, $sList, "") FileOpen($VariableFiles & "\Option2", 1) Case $add _AddList() Case $clear GUICtrlSetData($List2, "", "") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _AddList() Local $aList = _GUICtrlListBox_GetSelItemsText($List1) Local $sList = _ArrayToString($aList, "|", 1, -1) GUICtrlSetData($List2, $sList, "") If IsArray($aList) Then For $i = 0 to $aList[0] MsgBox($MB_SYSTEMMODAL, "Array Info", "Array Text: " & $aList[$i],1) FileOpen($VariableFiles & "\" & $aList[$i],1) Next EndIf EndFunc Thanks, Trinnon OptionList2.txt OptionList.txt Link to comment Share on other sites More sharing options...
pixelsearch Posted October 25 Share Posted October 25 6 hours ago, Trinnon said: The only thing it does that I don't need is it creates a file with the number of items selected. You can prevent all useless files creation by starting your loop with 1 : ; For $i = 0 to $aList[0] For $i = 1 to $aList[0] Link to comment Share on other sites More sharing options...
Nine Posted October 26 Share Posted October 26 Also, FileClose all files you open. If you don't, it will create some memory leaks that you may end up missing memory in the long run... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Trinnon Posted October 29 Author Share Posted October 29 Awesome. I have added both of those to the app. 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