gcue Posted March 31, 2009 Share Posted March 31, 2009 i have an array which is a software list i would like the user to be able to enter a keyword to search. so if the user enters "acrobat", "adobe acrobat professional" and "acrobat reader" would be a match. what does the stringregexp look like for this? For $x = 1 To $softwarelist[0] $progy = StringRegExp(GUICtrlRead($program)... ;program entered by user If $proggy = $softwarelist[$x] Then FileWrite($file, $proggy) EndIf Next thank you for your help =) Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 (edited) Do you mean something like this? #include<array.au3> $Ctrl = GUICtrlCreateInput(""........) For $i = 1 To Ubound($aArray) -1 If StringRegExp($aArray[$i], "(?i)" & GUICtrlRead($Ctrl)) Then $aRtn = StringRegExp($aArray[$i], "(?i).*" & GUICtrlRead($Ctrl) & ".*"), 3) If NOT @Error Then _ArrayDisplay($aRtn, GUICtrlRead($Ctrl) & " Results") EndIf EndIf Next Edited March 31, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 gonna try now - ill let u know! thanks! Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 Actually I thought of something after that reply. Why do you need a RegExp? You should just need StringInStr() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
WideBoyDixon Posted March 31, 2009 Share Posted March 31, 2009 Or if it's really an array, perhaps _ArrayFindAll() ? [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) hmm getting an error... cant see why that line is erroring.. ERROR: syntax error $aRtn = StringRegExp($softwarelist[$i], "(?i).*" & GUICtrlRead($software) & ".*"), $softwarelist = _InstalledSoftware($asset[$i][1]) For $i = 1 To UBound($softwarelist) - 1 If StringRegExp($softwarelist[$i], "(?i)" & GUICtrlRead($software)) Then $aRtn = StringRegExp($softwarelist[$i], "(?i).*" & GUICtrlRead($software) & ".*"), 3) If Not @error Then _ArrayDisplay($aRtn, GUICtrlRead($software) & " Results") EndIf EndIf Next Do you mean something like this? #include<array.au3> $Ctrl = GUICtrlCreateInput(""........) For $i = 1 To Ubound($aArray) -1 If StringRegExp($aArray[$i], "(?i)" & GUICtrlRead($Ctrl)) Then $aRtn = StringRegExp($aArray[$i], "(?i).*" & GUICtrlRead($Ctrl) & ".*"), 3) If NOT @Error Then _ArrayDisplay($aRtn, GUICtrlRead($Ctrl) & " Results") EndIf EndIf Next Edited March 31, 2009 by gcue Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 $aRtn = StringRegExp($aArray[$i], "(?i).*" & GUICtrlRead($Ctrl) & ".*", 3) Just realized thit it might not do what you want anyway. _ArrayGetAll() is a good method to use for this really or Just StringInStr() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 i cant find _arraygetall.. in the history of releases nor anywhere else in the forum.. do you have a link? =) thanks geo Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 i cant find _arraygetall.. in the history of releases nor anywhere else in the forum..do you have a link? =)thanks geoThat was my fault. It's _ArrayFindAll()... HelpFile under User Defined Functions>>Array Management George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 ok so far i have this: $softwarelist = _InstalledSoftware($asset[$i][1]) $searchresults = _ArrayFindAll($softwarelist, GUICtrlRead($software), 0, 0, 0, 1) _ArrayDisplay($searchresults) but i get number values as a return.. when i _arraydisplay $softwarelist i get a list of the apps installed on pc ($asset[$i][1]) any ideas? Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 (edited) $softwarelist = _InstalledSoftware($asset[$i][1]) $searchresults = _ArrayFindAll($softwarelist, GUICtrlRead($software), 0, 0, 0, 1) For $i = 1 To Ubound($SearchResults) -1 MsgBox(0, "Result " & $i, $SoftwareList[$SearchResults[$i]]) Next Edited March 31, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted March 31, 2009 Share Posted March 31, 2009 Also as I've previously pointed out (twice) this can be done simply with StringInStr($softwarelist[$i][1], $input). George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 cool we're getting somewhere! but it just reports only one search result. $softwarelist = _InstalledSoftware($asset[$i][1])oÝ÷ Ú[HÔLND³ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 31, 2009 Moderators Share Posted March 31, 2009 (edited) If you read the help file, it would show you that it returns the "indexes" of the found values, not the actual string value itself. This means you have to go outside the box and do a little manipulation yourself on retrieving the index values found out of the array you actually sent. Edit: You can even create your own type (I did this one a long time ago before _ArrayFindAll() existed. It works only on 1 dimensional arrays, it returns a 2 dimensional array, [n][0] (2nd dimension, 0 index) returns the index it was found in the original array, [n][1] (2nd dimension, index 1) returns the string value found for that index.expandcollapse popup#include <array.au3> Global $a_tmp[3] = ["apple", "orange", "strange"] Global $a_ret = _array_find_matches($a_tmp, "ran") _ArrayDisplay($a_ret) ; Return a 2D array [n][0] = index number in original array: [n][1] = match string value ; $f_exact_match is not case sensitive, unless $f_case_sensitive is set to true Func _array_find_matches($a_array, $s_match, $i_base = 0, $f_exact_match = False, $f_case_sensitive = False) Local $i_case = 0 If $f_case_sensitive Then $i_case = 1 Local $i_ub = UBound($a_array) If $i_ub - 1 < $i_base Then Return SetError(1, 0, 0) Local $a_ret_array[$i_ub][2], $i_add = 0 For $i = $i_base To $i_ub - 1 If $f_exact_match Then If $f_case_sensitive Then If ($a_array[$i] == $s_match) Then $a_ret_array[$i_add][0] = $i $a_ret_array[$i_add][1] = $a_array[$i] $i_add += 1 EndIf Else If $a_array[$i] = $s_match Then $a_ret_array[$i_add][0] = $i $a_ret_array[$i_add][1] = $a_array[$i] $i_add += 1 EndIf EndIf ElseIf StringInStr($a_array[$i], $s_match, $i_case) Then $a_ret_array[$i_add][0] = $i $a_ret_array[$i_add][1] = $a_array[$i] $i_add += 1 EndIf Next If Not $i_add Then Return SetError(2, 0, 0) ReDim $a_ret_array[$i_add][2] Return $a_ret_array EndFunc Edited March 31, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 this was getting overtly complicated.. so i followed ur advice geo.. $softwarelist = _InstalledSoftware($asset[$i][1]) For $z = 1 To $softwarelist[0] $searchresults = StringInStr($softwarelist[$z], GUICtrlRead($software)) If $searchresults <> 0 Then FileWrite($file, '' & @CRLF & _ $asset[$i][0] & "," & $asset[$i][1] & "," & $sections[$x] & "," & $softwarelist[$z]) EndIf Next thanks for your help everyone! Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) if GUICtrlRead($software) is more than two words.. how can i account for the spaces as a wildcard? for instance: if someone searches for Sametime 7.5 - Sametime Connect 7.5 would come back as a match $softwarelist = _InstalledSoftware($asset[$i][1]) For $z = 1 To $softwarelist[0] $searchresults = StringInStr($softwarelist[$z], GUICtrlRead($software)) If $searchresults <> 0 Then FileWrite($file, '' & @CRLF & _ $asset[$i][0] & "," & $softwarelist[$z]) EndIf Next Edited March 31, 2009 by gcue Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 31, 2009 Share Posted March 31, 2009 I would be much easier, if you just use the software list as a normal string an then search the string with StringInStr or RegExp Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) hmmm not sure what you mean.. "normal string?" Edited March 31, 2009 by gcue Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 31, 2009 Share Posted March 31, 2009 hmmm not sure what you mean.. "normal string?"Just like _ArrayToString. So at the end you have a string to search on like:$installedSoftware = 'Autoit 3|Lotus Notes|Irfan View|...'Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
gcue Posted March 31, 2009 Author Share Posted March 31, 2009 how would that help with the wildcard thing? thanks for your help xeno 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