Jump to content
Sign in to follow this  
igorm

Search and count

Recommended Posts

Hi,

I need to make a script which will search for specified word in .ini files and as return I need number of found items. Search need to find partial results. For example if I search for word "do" I need that search counts every work which contain "do". I don't need any GUI. I need this for some script I'm writing but I'm stuck here. I searched a lot in help file and in this forum but I could not find what I need. I hope someone can help me. Thanks.

Cheers :)

Share this post


Link to post
Share on other sites

StringInStr and StringRegExp is what you are looking for.

But, StringRegExp is what i personaly think is the best one.

Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Heres an example using stringregexp:

$text = "We do alot, don't we? Yes we do."
$search = "do"
$count = StringRegExp($text, $search, 3)
ConsoleWrite("Instance "&$search&" was found: "&UBound($count)&" times."&@CRLF)

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Hi,

you can also StringReplace searchword with searchword and then check extended.

So long,

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

Share this post


Link to post
Share on other sites

IniReadSectionNames --> StringRegExp --> IniRead, would work.


UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Thanks again, that was my first thought, but I still can not figure it. Here's what I wrote and as result I always get number 1 even if .ini file has more then that. I need to search only in [sectionName]. Here it is(this is not my whole script, it is just part for the count) :

$inifilelistone = _FileListToArray($path22 & '\FILES\SETUP','setup*.ini',1)
$inifileone = $path22 & '\FILES\SETUP\'&$inifilelistone[1]
$stringsearchone = IniReadSectionNames($inifileone)
For $p = 1 To $stringsearchone[0]
$y = StringRegExp($stringsearchone,"ChainedInstall_", 3)
Next

I also add this to check the $y but I always get number 1:

MsgBox(0, "test", $y)

Can you tell me what I'm doing wrong?

Thanks.

Cheers :)

EDIT: OK, I got it. I needed _ArrayToString to get it right.

Now it looks like this:

inifilelistone = _FileListToArray($path22 & '\FILES\SETUP','setup*.ini',1)
                $inifileone = $path22 & '\FILES\SETUP\'&$inifilelistone[1]
                $stringsearchone = IniReadSectionNames($inifileone)
                

                    $string1 = _ArrayToString ($stringsearchone, "|")
                    $y= StringRegExp($string1, "ChainedInstall", 3)
                    $z = UBound($y)

And it works perfect. Thank you guys again.

Edited by igorm

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  

×
×
  • Create New...