dirty Posted September 15, 2011 Share Posted September 15, 2011 (edited) This function finds file/reads it and if match display it in ListView that i later need to read (each displayed search result) Func _searchName($dir) Local $ArrTargetItems, $TargetItem If (StringRight($dir, 1) = "\") Then $dir = StringTrimRight($dir, 1) $ArrTargetItems = _FileListToArray($dir, "*", 0) If IsArray($ArrTargetItems) Then For $n = 1 To $ArrTargetItems[0] $TargetItem = $dir & '\' & $ArrTargetItems[$n] If StringInStr(FileGetAttrib($TargetItem), "D") Then ;This is a folder _searchName($TargetItem) ;Call recursively Else ;This is a file If StringRight ($TargetItem,4) = ".ini" Then $GetNameFromResult = IniRead ($TargetItem,"Project","Name","") $GetCountFromResult = IniRead ($TargetItem,"Project","Count","") $GetNumberFromResult = IniRead ($TargetItem,"Project","Number","") $GetCategoryFromResult = IniRead ($TargetItem,"Project","Category","") $GetLocationFromResult = IniRead ($TargetItem,"Project","Location","") If StringInStr ($GetNameFromResult, GUICtrlRead ($SearchByName)) > 0 Then ;display result based on Name GUICtrlCreateListViewItem ($GetNameFromResult & "|" & $GetCountFromResult & "|" & $GetNumberFromResult & "|" & $GetCategoryFromResult & "|" & $GetLocationFromResult,$Results) EndIf EndIf EndIf Next EndIf EndFunc How to i make displayed result's (when many) readable by guictrlread if GUICtrlCreateListViewItem when created has no variable assigned ? GUICtrlCreateListViewItem is created for each result, so it needs to be created under new variable each time How do i do this ? Thanks in advance. Edited September 15, 2011 by dirty Link to comment Share on other sites More sharing options...
Juvigy Posted September 15, 2011 Share Posted September 15, 2011 Best thing to do is create an array and dinamically adjusting it using REDIM and UBOUND Link to comment Share on other sites More sharing options...
dirty Posted September 15, 2011 Author Share Posted September 15, 2011 Can you give an example that i can implement into this function without changing it ? Since i dont know what Redim and Ubound do, i am clueless what you talk about, but sure if you provide an example (as simple as possible) i will learn. Thanks for quick reply. This project takes more time then rewriting bible (not fare) so i thought i'd ask for help to speed it up Link to comment Share on other sites More sharing options...
Juvigy Posted September 15, 2011 Share Posted September 15, 2011 Creates array with 4 elements (0 to 3) Dim $X[4] ReDeim $X[5] takes the prev array and adds another new empty element at the end. Ubound($X) gives you how many elements the array has. You can check it all in the help file. Link to comment Share on other sites More sharing options...
Akarillon Posted September 15, 2011 Share Posted September 15, 2011 If you are stuck with not knowing what a function do, always check the help file (F1) and use the Index(search for names of the functions) or Search(you know some word that has to do with the function) tabs. Challenge accepted! Link to comment Share on other sites More sharing options...
monoscout999 Posted September 15, 2011 Share Posted September 15, 2011 My guess will be this.. Global $aArray[1] = [999999] ; At the top of the script $hGui = GuiCreate("Test") $Button = GuiCtrlCreateButton("Add 1 Item",10,10,100,30) $iListView = GuiCtrlCreateListView("Let See",10,50,380,330) $aArray[0] = $iListView ; I have to put some value in this index because it gives me some errors in the msgloop GuiSetState() While True $iMsg = GuiGetMsg() Switch $iMsg case -3 Exit case $Button Redim $aArray[Ubound($aArray) + 1] $aArray[Ubound($aArray) - 1] = GuiCtrlCreateListViewItem("New Item",$iListView) case $aArray[0] to $aArray[Ubound($aArray) - 1] If $iMsg = $iListView then ContinueCase MsgBox(0,"ListViewItem", "You have Clicked in the item ID "&$iMsg) EndSwitch WEnd Link to comment Share on other sites More sharing options...
dirty Posted September 15, 2011 Author Share Posted September 15, 2011 Cool thanks. But how come return value is always numbers instead of whats in the listview separated by | ? If guictrlsetdata ($listView,"Item1|Item2") then why guictrlread ($listView) does not return string that is in those columns separated by | ? Link to comment Share on other sites More sharing options...
BrewManNH Posted September 15, 2011 Share Posted September 15, 2011 Listviews are unique in that you have to read the contents of a selected item like this GUICtrlRead(GUICtrlRead($Listview)) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
dirty Posted September 16, 2011 Author Share Posted September 16, 2011 (edited) AH THANK YOU SO MUCH !!!!! GUICtrlRead(GUICtrlRead($Listview)) Return is now Lacrimal Duct Probes Set of 5|1|N/A|General|General cart|Now how do i separate those so that Lacrimal Duct Probes Set of 5 go into one input field and so on ?Not sure how to string modify this string to separate it by pieces Edited September 16, 2011 by dirty Link to comment Share on other sites More sharing options...
BrewManNH Posted September 16, 2011 Share Posted September 16, 2011 You can separate them by using StringSplit. $ListviewItemText = GUICtrlRead(GUICtrlRead($Listview)) $SplitLineArray = StringSplit($ListviewItemText, "|") This will create an array ($StringSplitArray), where element [0] is the number of items in the array, the [1] element would have "Lacrimal Duct Probes Set of 5", [2] would equal "1" [3] would equal "N/A", etc. You could then use the array to populate your input boxes. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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