Revision: 25
Author: kim.john.burgess
Date: Thu May 13 04:14:11 2010
Log: - Modified find_string_multi() to behave in the way it was originally
intended. It now searches for any match from a selection of needles within
a single haystack. Apologies for the premature commit (I've now ordered a
nasal spray of the net to help out with this).
http://code.google.com/p/amx-netlinx-common/source/detail?r=25
Modified:
/trunk/String.axi
=======================================
--- /trunk/String.axi Wed May 12 23:25:02 2010
+++ /trunk/String.axi Thu May 13 04:14:11 2010
@@ -619,28 +619,26 @@
}
/**
- * Returns the index of the first occurance of a string within a passed
array
- * of strings.
+ * Search through a string for a match against a list of possible
substrings
+ * and return the element index of the matched string
*
- * @param haystack an array of strings to search
- * @param str the character sequence to search for
+ * @param haystack a string to search
+ * @param needle a list of substrings to match
* @param start the array element to begin searching from
- * @return an integer containing the the index of haystack in
- * which the string was located (0 if not found)
+ * @return an integer containing the the element index of needles
+ * that was matched (0 if not found)
*/
-define_function integer find_string_multi(char haystack[][], char needle[],
+define_function integer find_string_multi(char haystack[], char
needles[][],
integer start)
{
stack_var integer i
stack_var integer len
- len = length_array(haystack)
-
- if (start <= len) {
- for (i = start; i <= len; i++) {
- if (find_string(haystack[i], needle, 1)) {
- return i
- }
+ len = length_array(needles)
+
+ for (i = start; i <= len; i++) {
+ if (find_string(haystack, needles[i], 1)) {
+ return i
}
}