Sign in to follow this  
Followers 0
theguy0000

New _ArraySearch

8 posts in this topic

#1 ·  Posted (edited)

I am hoping for this to eventually replace the old _ArraySearch function....

It is a new _ArraySearch function with much more options.

Replacing your old version with my new version will of course not break any of your old scripts since I only added one optional parameter.

Anyways....it has a new parameter $iFlag

The old _ArraySearch only matches if the searchstring matches exactly the element, no option for partial matches. I added that, but still thought it was too limited. So, here you go:

$iFlag (Optional) = How to match the search string.

Possible Values:

0 - (Default) Exact match

1 - match at beginning of element

2 - match at end of element

3 - anywhere in element

4 - Regular Expression (if used, $iCaseSense is ignored)

Example:

(from the help file, just modified)

#Include<Array.au3>
Dim $Array[6]
$Array[0] = "String0"
$Array[1] = "String1"
$Array[2] = "String2"
$Array[3] = "String3"
$Array[4] = "String4"
$Array[5] = "String5"

$Input = InputBox("ArraySearch Demo", "String To Find?")
$flag = Int(InputBox ("ArraySearch Demo", "Flag?"))
If @error Then Exit

$Pos = _ArraySearch ($Array, $Input, 0, 0, 0, $flag)
Select
    Case $Pos = -1
        MsgBox(0, "Not Found", '"' & $Input & '" was not found in the array.')
    Case Else
        MsgBox(0, "Found", '"' & $Input & '" was found in the array at pos ' & $Pos & ".")
EndSelectoÝ÷ Ù:òºÈ§«¨¶Úâ
=ÙÚ®¢Ü"¶åj*ºR¶¸ªºpØ_¨5ªê-JÚâ
êºpØ_¨4ªê-x6ªê-Â+a~V Ú«¨¶)àªê-Â+a~V Ý8h±ì(ºWZYµÈl¢g­)à{ayªëk(^­ë-ç(uç(uæèÅ«­¢+Øìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(ì(ìÍÉ¥ÁÑ¥½¸è¥¹Ì¸¹ÑÉäݥѡ¥¸½¹µ¥µ¹Í¥½¹°ÉÉ両M¥µ¥±ÈѼ}ÉÉå    ¥¹ÉåMÉ  ¤áÁÐÑ¡ÉÉä½Ì¹½Ð¹Ñ¼Í½ÉѸ¤(ìMå¹Ñàè}ÉÉåMÉ  ÀÌØíÙÉÉä°ÀÌØíÙ]¡ÐÉ¥¹°ÀÌØí¥MÑÉÐôÀ°ÀÌØí¥¹ôÀ°ÀÌØí¥
ÍM¹ÍôÀ¤(ì(ìAɵÑȡ̤èÀÌØíÙÉÉäôQ¡ÉÉäѼÍÉ (ìÀÌØíÙ]¡ÐÉ¥¹ô]¡ÐѼÍÉ ÀÌØíÙÉÉä½È(ìÀÌØí¥MÑÉС=ÁÑ¥½¹°¤ôMÑÉÐÉÉ䥹à½ÈÍÉ °¹½Éµ±±äÍÐѼÀ½Èĸ%½µ¥ÑѥХÌÍÐѼÀ(ìÀÌØí¥¹¡=ÁÑ¥½¹°¤ô¹ÉÉ䥹à½ÈÍÉ ¸%½µ¥ÑѽÈÍÐѼÀ¥Ð¥ÌÍÐѼU½Õ¹ ÀÌØíÙÉÉ䤴(ì$$$$$ÀÌØí¥
ÍM¹Í¡=ÁÑ¥½¹°¤ô%ÍÐѼÄÑ¡¸ÍÉ ¥ÌÍ͹ͥѥÙ(ì$$$$$ÀÌØí¥±¡=ÁÑ¥½¹°¤ô!½ÜѼµÑ Ñ¡ÍÉ ÍÑÉ¥¹¸(ì$$$$$%A½ÍÍ¥±Y±ÕÌè(ì$$$$$$$À´¡Õ±Ð¤áÐµÑ (ì$$$$$$$Ä´µÑ Ð¥¹¹¥¹½±µ¹Ð(ì$$$$$$$È´µÑ й½±µ¹Ð(ì$$$$$$$Ì´¹åÝ¡É¥¸±µ¹Ð(ì$$$$$$$дIÕ±ÈáÁÉÍÍ¥½¸¡¥ÕÍ°ÀÌØí¥
ÍM¹Í¥Ì¥¹½É¤(ìIÅեɵ¹Ð¡Ì¤è9½¹(ì(ìIÑÕɸY±Õ¡Ì¤è=¸MÕÍÌ´IÑÕɹÌÑ¡Á½Í¥Ñ¥½¸½¸¥Ñ´¥¸¸ÉÉä¸(ì=¸¥±ÕÉ´IÑÕɹ̸´Ä¥ÀÌØíÙ]¡ÐÉ¥¹¥Ì¹½Ð½Õ¹(ìÉɽÈôÄÀÌØíÙÉÉä¥Ì¹½Ð¸ÉÉä(ìÉɽÈôÈÀÌØí¥MÑÉÐ¥ÌÉÑÈÑ¡¸U   ½Õ¹ ÀÌØíÙÉÉ䤴Ä(ìÉɽÈôÌÀÌØí¥¹¥ÌÉÑÈÑ¡¸U   ½Õ¹ ÀÌØíÙÉÉ䤴Ä(ìÉɽÈôÐÀÌØí¥MÑÉÐ¥ÌÉÑÈÑ¡¸ÀÌØí¥¹(ì$$$$$$ÉɽÈôÔÀÌØí¥
ÍM¹ÍÝÌ¥¹Ù±¥¸¡5ÕÍÐÀ½ÈĤ(ì$$$$$$ÉɽÈôØÀÌØíÙ]¡ÐÉ¥¹Ý̹½Ð½Õ¹¥¸ÀÌØíÙÉÉä(ì$$$$$$ÉɽÈôÜ%¹Ù±¥ÀÌØí¥±ÁɵÑÈ(ì(ìÕÑ¡½È¡Ì¤èM½±¥M¹­±Ðí5ѱÉ`äÄÐ!½Ñµ¥°½Ð½´ÐììÑ¡ÕäÀÀÀ±ÐíÑ¡ÕäÀÀÀÀе¥°½Ð½´Ðì(ì9½Ñ¡Ì¤èQ¡¥Ìµ¥¡Ðͱ½ÝÈÑ¡¸}ÉÉå ¥¹ÉåMÉ  ¤ÕÐ¥ÌÕÍÕ°Ý¡¸Ñ¡ÉÉäÌäí̽ÉȸÌäíбÑɸ(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô)Õ¹}ÉÉåMÉ ¡
½¹ÍР   åIÀÌØíÙÉÉä°ÀÌØíÙ]¡ÐÉ¥¹°ÀÌØí¥MÑÉÐôÀ°ÀÌØí¥¹ôÀ°ÀÌØí¥
ÍM¹ÍôÀ°ÀÌØí¥±ôÀ¤(%1½°ÀÌØí¥
ÕÉɹÑA½Ì°ÀÌØí¥U    ½Õ¹(%%9½Ð%ÍÉÉä ÀÌØíÙÉÉä¤Q¡¸($%MÑÉÉ½È Ä¤($%IÑÕɸ´Ä(%¹%($ÀÌØí¥U    ½Õ¹ôU   ½Õ¹ ÀÌØíÙÉÉ䤴Ä(%%ÀÌØí¥¹ôÀQ¡¸ÀÌØí¥¹ôÀÌØí¥U  ½Õ¹(%%ÀÌØí¥MÑÉÐÐìÀÌØí¥U   ½Õ¹Q¡¸($%MÑÉÉ½È È¤($%IÑÕɸ´Ä(%¹%(%%ÀÌØí¥¹ÐìÀÌØí¥U   ½Õ¹Q¡¸($%MÑÉÉ½È Ì¤($%IÑÕɸ´Ä(%¹%(%%ÀÌØí¥MÑÉÐÐìÀÌØí¥¹Q¡¸($%MÑÉÉ½È Ð¤($%IÑÕɸ´Ä(%¹%(%%9½Ð ÀÌØí¥
ÍM¹ÍôÀ=ÈÀÌØí¥
ÍM¹ÍôĤQ¡¸($%MÑÉÉ½È Ô¤($%IÑÕɸ´Ä(%¹%(%%ÀÌØí¥±±ÐìÀ=ÈÀÌØí¥±ÐìÐQ¡¸($%MÑÉÉ½È Ü¤($%IÑÕɸ´Ä(%¹%(%½ÈÀÌØí¥
ÕÉɹÑA½ÌôÀÌØí¥MÑÉÐQ¼ÀÌØí¥¹($%M±Ð($$%
ÍÀÌØí¥
ÍM¹ÍôÀ($$$%MÝ¥Ñ ÀÌØí¥±($$$$%
ÍÀ($$$$$%%ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½ÍtôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÄ($$$$$%%MÑÉ¥¹1Ð ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°MÑÉ¥¹1¸ ÀÌØíÙ]¡ÐÉ¥¹¤¤ôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÈ($$$$$%%MÑÉ¥¹I¥¡Ð ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°MÑÉ¥¹1¸ ÀÌØíÙ]¡ÐÉ¥¹¤¤ôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÌ($$$$$%%MÑÉ¥¹%¹MÑÈ ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°ÀÌØíÙ]¡ÐÉ¥¹¤Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÐ($$$$$%%MÑÉ¥¹IáÀ ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°ÀÌØíÙ]¡ÐÉ¥¹¤Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$%¹MÝ¥Ñ ($$%
ÍÀÌØí¥
ÍM¹ÍôÄ($$$%MÝ¥Ñ ÀÌØí¥±($$$$%
ÍÀ($$$$$%%ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½ÍtôôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÄ($$$$$%%MÑÉ¥¹1Ð ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°MÑÉ¥¹1¸ ÀÌØíÙ]¡ÐÉ¥¹¤¤ôôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÈ($$$$$%%MÑÉ¥¹I¥¡Ð ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°MÑÉ¥¹1¸ ÀÌØíÙ]¡ÐÉ¥¹¤¤ôôÀÌØíÙ]¡ÐÉ¥¹Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÌ($$$$$%%MÑÉ¥¹%¹MÑÈ ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°ÀÌØíÙ]¡ÐÉ¥¹°Ä¤Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$$%
ÍÐ($$$$$%%MÑÉ¥¹IáÀ ÀÌØíÙÉÉålÀÌØí¥
ÕÉɹÑA½Ít°ÀÌØíÙ]¡ÐÉ¥¹¤Q¡¸($$$$$$%MÑÉÉ½È À¤($$$$$$%IÑÕɸÀÌØí¥
ÕÉɹÑA½Ì($$$$$%¹%($$$%¹MÝ¥Ñ ($%¹M±Ð(%9áÐ(%MÑÉÉ½È Ø¤(%IÑÕɸ´Ä)¹Õ¹ìôôÐí}ÉÉåMÉ

Have fun ;)

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It is very good. What about returning an optional array of matches (or an array of positions)?

Edit: I think @error should return 1 instead of 6 if $vWhat2Find is not found.

Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I like the new features. ;) They should prove useful to many people. You should also credit yourself under the Author(s) being you added a significant amount of functinality. Would you mind if I merged this with my MultiDimensional _ArraySearch?

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

It is very good. What about returning an optional array of matches (or an array of positions)?

Edit: I think @error should return 1 instead of 6 if $vWhat2Find is not found.

Hmm...I could definitely do the array thing...but as for the @error value, I want this to be able to replace people's _ArraySearch functions without breaking scripts that use the old version...

I like the new features. ;) They should prove useful to many people. You should also credit yourself under the Author(s) being you added a significant amount of functinality. Would you mind if I merged this with my MultiDimensional _ArraySearch?

Thank you, and yes I forgot to put myself in the authors :"> thanks

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

@solidsnake....I just saw your second question...

And of course I wouldn't mind if you included it in your multi dim array search ;)


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

That sure does look familiar, down to the var names even.


[center]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.[/center]

Share this post


Link to post
Share on other sites

That sure does look familiar, down to the var names even.

it is of course only a modified version of the original. Notice I kept SolidSnake in the Author section.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

I like the new features. ;) They should prove useful to many people. You should also credit yourself under the Author(s) being you added a significant amount of functinality. Would you mind if I merged this with my MultiDimensional _ArraySearch?

Let us know when it's updated. This version of _ArraySearch is great as is your MultiDimensional search.

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0