Jump to content

_ArraySearch not working?


nitekram
 Share

Recommended Posts

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 by nitekram

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."

 

WindowsError.gif

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

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 by Danyfirex
Link to comment
Share on other sites

  • Moderators

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')
EndIf
Or have I misunderstood the question? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by nitekram

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

That makes even less sense than the first post. :wacko:

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
EndIf
But I am not entirely sure I have your desired outcome correct. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

nitekram,

That makes even less sense than the first post. :wacko:

...

But I am not entirely sure I have your desired outcome correct. :D

M23

I 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.

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

No probs - I know the feeling! :D

m23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...