Need help on which function/method to use [SOLVED]
-
Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.
modified on Monday, October 26, 2009 11:13 AM
-
Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.
modified on Monday, October 26, 2009 11:13 AM
-
Hi all, I'm working on a application which searches for '_FLEX' or '_FLEX_' or '_CABLE' or _'FERME' in a text file. If found do some action. I use the below code to set the index to search for the above words. Issue: There is a line in the text file in the name fields with '_FLEX1'. When this word is found, it does the actions that need to be done for lpFlex or lpFlex_ found. I have used name.IndexOf for '_FLEX' and '_FLEX_' but when found'_FLEX1', it has performed the actionsof lpFlex or lpFlex_. I dont want any action to be done when something other than lpFlex or lpCable or lpFeme or lpFlex_ found. I think its because I use name.IndexOf(). Is there some other function/method to search for the specific word in a field/line? Where am I going wrong? Any help and suggestion please. Thanks in Advance.
modified on Monday, October 26, 2009 11:13 AM
If I understand your question correctly, you only want the action to happen if an exact match is found for one of your trigger words. This might be very difficult, although it partly depends on what character 'should' follow them. For example, if they should always be followed by a space, then test for "_FLEX ", "_CABLE " etc. If "_FLEX1", is guaranteed to be the only 'problem' then a test like:
If sampleText.SubString(resultOfIndexOf, 6) = "_FLEX1" THEN Return 'or whatever will ignore that entry
If they can be followed by anything then it would be extremely difficult. It may be possible by using Regular Expressions but I do not have sufficient skills in that area to say for sure. If after a couple more hours no-one has offered a solution I suggest that you post a new question with a title like "Regular Expression problem", that will usually attract the Expressionistas. If you do that, please be sure to mention that you asked earlier but got no luck but someone suggested RE might do the trick. Good Luck! :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
If I understand your question correctly, you only want the action to happen if an exact match is found for one of your trigger words. This might be very difficult, although it partly depends on what character 'should' follow them. For example, if they should always be followed by a space, then test for "_FLEX ", "_CABLE " etc. If "_FLEX1", is guaranteed to be the only 'problem' then a test like:
If sampleText.SubString(resultOfIndexOf, 6) = "_FLEX1" THEN Return 'or whatever will ignore that entry
If they can be followed by anything then it would be extremely difficult. It may be possible by using Regular Expressions but I do not have sufficient skills in that area to say for sure. If after a couple more hours no-one has offered a solution I suggest that you post a new question with a title like "Regular Expression problem", that will usually attract the Expressionistas. If you do that, please be sure to mention that you asked earlier but got no luck but someone suggested RE might do the trick. Good Luck! :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Thanks for your reply. I have changed tthe below from:
lpFlex = name.IndexOf("_FLEX")
lpCable = name.IndexOf("_CABLE")
lpFerme = name.IndexOf("_FERME")
lpFlex_ = name.IndexOf("_FLEX_")to:
lpFlex = name.IndexOf("_FLEX.")
lpCable = name.IndexOf("_CABLE_")
lpFerme = name.IndexOf("_FERME_")
lpFlex_ = name.IndexOf("_FLEX_")which solved my purpose. when there is a _FLEX. or _FLEX_ found, the application does some action when something else other than these found, it will be written as such. The written line will be processed by another function in my application and will be removed from the text file. Anyways thanks for this suggestion. Will make use of it some where else.