WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: seckner on February 21, 2018, 01:44:56 PM

Title: Array Searching
Post by: seckner on February 21, 2018, 01:44:56 PM
Attached is a very small sample file from a Robocopy log. I'm using ArrayFileGet to load the attached file into an array. Now I want to search the attay and count how many times  "(0x00000005)" is found throughout the array and that should be 2. How do I search for a portion of the line? The only what I've gotten anything back is to ArraySearch or ArrayLocate the entire string:

ArrayLocate(array, "2018/02/21 15:05:37 ERROR 5 (0x00000005) Copying File \\Server\Shares\Person\misc\Toot my horn.pdf") finds the line but obviously wont find the second because the time changes.

The original file is 9000+ lines long and there will be around 100 or more of them so I'm hoping for something other than line by line if it can be done. Is it possible?
Title: Re: Array Searching
Post by: JTaylor on February 21, 2018, 02:01:52 PM
Not sure the array approach is the best way.   Perhaps the Binary functions?

Jim
Title: Re: Array Searching
Post by: seckner on February 21, 2018, 06:00:09 PM
Never used them before, guess it's time to learn! Thank you Jim.
Title: Re: Array Searching
Post by: JTaylor on February 21, 2018, 06:19:13 PM
There is more than one way, as usual, but the BinaryTagInit() example would get you started and give you most everything you need.

Jim