igorm Posted December 17, 2007 Posted December 17, 2007 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 Office 2000/XP/2003/2007 Slipstreamer
jokke Posted December 17, 2007 Posted December 17, 2007 (edited) StringInStr and StringRegExp is what you are looking for. But, StringRegExp is what i personaly think is the best one. Edited December 17, 2007 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.
igorm Posted December 18, 2007 Author Posted December 18, 2007 (edited) I'm afraid that I don't understand how to get as return number of found items using this what you suggested. Can you please post an example? Thanks. Cheers EDIT: OK, I got it now. Thanks. I used StringInStr. Edited December 18, 2007 by igorm Office 2000/XP/2003/2007 Slipstreamer
jokke Posted December 18, 2007 Posted December 18, 2007 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.
Xenobiologist Posted December 18, 2007 Posted December 18, 2007 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
igorm Posted December 18, 2007 Author Posted December 18, 2007 (edited) Thank you both, I learned something new today. I was not satisfy with StringInStr so I'm glad that you guys wrote this. Cheers EDIT: But, how to search in a file (.ini file)? Edited December 18, 2007 by igorm Office 2000/XP/2003/2007 Slipstreamer
jokke Posted December 18, 2007 Posted December 18, 2007 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.
igorm Posted December 18, 2007 Author Posted December 18, 2007 (edited) 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 December 18, 2007 by igorm Office 2000/XP/2003/2007 Slipstreamer
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