nitekram Posted February 13, 2014 Share Posted February 13, 2014 (edited) I have been messing around with this function for some time, and it is always a hit or miss for me. I hope that this has not already been discussed, but why does it not find certain characters. Any ideas on how to make this right? EDIT shoot, I have to add the other part...sorry #include<array.au3> Global $aArray1[3] = ['.', '?', '244<-->junk/[64599<-->64599]'] Global $aArray2[3] = ['.', '?', '<-->'] If _ArraySearch($aArray1, '<-->') = -1 Then MsgBox('', 'array 1', 'why am I in here?') Else MsgBox('', 'array 1', 'PASS') EndIf If _ArraySearch($aArray2, '<-->') = -1 Then MsgBox('', 'array 2', 'why am I in here?') Else MsgBox('', 'array 2', 'PASS') EndIf Edited February 13, 2014 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Danyfirex Posted February 13, 2014 Share Posted February 13, 2014 (edited) Look the $iCompare Flag Look this mod...: #include<array.au3> Global $aArray1[3] = ['.', '?', '244<-->junk/[64599<-->64599]'] Global $aArray2[3] = ['.', '?', '<-->'] If _ArraySearch($aArray1, '<-->',0,0,0,1) = -1 Then MsgBox('', 'array 1', 'why am I in here?') Else MsgBox('', 'array 1', 'PASS') EndIf If _ArraySearch($aArray2, '<-->') = -1 Then MsgBox('', 'array 2', 'why am I in here?') Else MsgBox('', 'array 2', 'PASS') endif Saludos Edited February 13, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2014 Moderators Share Posted February 13, 2014 nitekram,The match is not made in the first array because there is not a complete element which matches the string - but if you use the "partial search" parameter it is found as a substring:#include<array.au3> Global $aArray1[3] = ['.', '?', '244<-->junk/[64599<-->64599]'] Global $aArray2[3] = ['.', '?', '<-->'] If _ArraySearch($aArray1, '<-->') = -1 Then MsgBox('', 'array 1', 'Not found') Else MsgBox('', 'array 1', 'Found') EndIf If _ArraySearch($aArray2, '<-->') = -1 Then MsgBox('', 'array 2', 'Not found') Else MsgBox('', 'array 2', 'Found') EndIf If _ArraySearch($aArray1, '<-->', 0, 0, 0, 1) = -1 Then ; Do a search for a partial match MsgBox('', 'array 1', 'Not found') Else MsgBox('', 'array 1', 'Found') EndIfOr have I misunderstood the question? M23 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...
nitekram Posted February 13, 2014 Author Share Posted February 13, 2014 (edited) Okay, now that I have confused myself on what it is that I exactly want... If the item contains the '<-->' then the value should be -1, as per help file. If the value '<-->' is found, I want skip the code and go to the next code. So my code should read If _ArraySearch($array, '<-->', 0, 0, 0, 1) = -1 Then ;continue code Else ;skipped code EndIf So is the above code correct in what I want to do? EDIT - added in the compare flag Edited February 13, 2014 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2014 Moderators Share Posted February 13, 2014 nitekram,That makes even less sense than the first post. If you want to see if the element contains the string "<->" then you need to use the "partial search" parameter as explained above. In that case the return will be -1 if the string is not found and 0+ if it is. So I think your code would need to be:If _ArraySearch($array, '<-->', 0, 0, 0, 1) = -1 Then ; Not found so - code Else ; Found so - continue EndIfBut I am not entirely sure I have your desired outcome correct. M23 Danyfirex and psbeau 2 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...
nitekram Posted February 13, 2014 Author Share Posted February 13, 2014 nitekram,That makes even less sense than the first post. ...But I am not entirely sure I have your desired outcome correct. M23I got it, I had to revisit my array in my script. You are correct, I have to use the "partial search" parameter. My problem was that I was not using the partial search, as well as not checking the whole string to begin with. I have found my error, and have fixed it on my side.Everyone was a big help, as my mind was going ape over this.p.s. Sorry for all the confusion...That is what happens when you are not sure of your input, nor your output. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2014 Moderators Share Posted February 13, 2014 nitekram,No probs - I know the feeling! m23 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...
mikell Posted February 13, 2014 Share Posted February 13, 2014 Sometimes a glance into the include to see how the function is built may be of great help 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