General XMetaL Discussion
MrPaul March 21, 2013 at 4:14 pm
Find Execute functionalityMarch 21, 2013 at 4:14 pmParticipants 1Replies 0Last Activity 9 years, 10 months ago
Using the Find().Execute function,
[code]Function Execute(Optional ByVal FindString As String = “”, Optional ByVal ReplaceString As String = “”,
Optional ByVal ConstraintString As String = “”, Optional ByVal MatchCase As Boolean = False,
Optional ByVal MatchWholeWords As Boolean = False, Optional ByVal MatchPatterns As Boolean = False,
Optional ByVal Forward As Boolean = True, Optional ByVal Wrap As Boolean = True,
Optional ByVal action As XMetaLControlLib.SQFindReplaceAction = sqFind,
Optional ByVal SetFindDialogOptions As Boolean = False) As Boolean
Member of XMetaLControlLib.Find[/code]
I am trying to search for text within a specific parent node. I have various conditions. Sometimes the text has to be within parent node A, sometimes it has to be within parent node B and NOT within parent node C. The way I'm accomplishing this right now is by looping through each find and checking if my conditions are met, and if so, I exit the Find loop. So far so good. The problem is that when it can't find text that matches my condition (i.e. the text exists but isn't under the parent node specified), it's causing an infinite loop because it keeps finding a match but I have no way to check if it wrapped around and back to the start item. I could manually code this, but I'm not sure how I could uniquely keep track of each found item.
I have two questions:
Is there an easier way to find text that belongs to a certain parent node (and sometimes also doesn't belong to a certain other parent node)? How are the ConstraintString or MatchPatterns parameters used in the Execute function above?
When iterating through each find result, the function is selecting the text for each match regardless of my conditions (when I really only want the end result to be selected). Is there a way to prevent the find from selecting the search text so I can explicitly do it myself? If so, how?
I'm using XMAX v6.
EDIT: If I could capture the exact line number and character position for each find result, I think that would solve my infinite loop problem. How can I get this info from the selection object?
- You must be logged in to reply to this topic.