public MWSelection findNextString(string theString, int startingIndex, string searchString) { MWSelection selectionObject = new MWSelection(); int i = startingIndex; if (startingIndex == -1) { i = 0; } while (i < (theString.Length - searchString.Length + 1) && selectionObject.getEndIndex() < 0) { if (theString[i] == searchString[0]) //possbile hit { //test if the word matches string testword = theString.Substring(i, searchString.Length); if (testword == searchString) { //we have a matching word selectionObject.setStartIndex(i); selectionObject.setEndIndex(i + searchString.Length - 1); } } ++i; }//end while return(selectionObject); }
public MWSelection findNextPotentialCall(int startingIndex) { MWSelection returnSelection = new MWSelection(); MWSelection nextStart = findStartDirection(startingIndex); MWSelection nextEnd = findEndDirection(startingIndex); MWSelection nextFeet = findFeet(startingIndex); int lenghthOfBearing = nextEnd.getEndIndex() - nextStart.getEndIndex(); bool potentialBearing = false; if (lenghthOfBearing >= 10 && lenghthOfBearing <= 25) { potentialBearing = true; } int lengthOfDistance = nextFeet.getEndIndex() - nextEnd.getEndIndex(); bool potentialDistance = false; if (lengthOfDistance >= 8 && lengthOfDistance <= 200) { potentialDistance = true; } if (potentialBearing == false || potentialDistance == false) { returnSelection.setEndIndex(-1); returnSelection.setStartIndex(-1); } else { returnSelection.setStartIndex(nextStart.getStartIndex()); returnSelection.setEndIndex(nextFeet.getEndIndex() + 1); } //if it is a potential call then it will return the position //if it does not look like the right lengths it will return -1 and -1 return(returnSelection); }