-
August 3rd, 2011, 08:19 AM
#1
[RESOLVED]Need to Check for a particular string
Hi,
I have a method LogFileContent(BSTR content).
I need to check the value which is present in content. I need to check for "Waiting for free XE Slot". If this string is present in content, i need to perform some executions.
How can I achieve this?
Regards
Last edited by p_zshk; August 4th, 2011 at 10:08 PM.
Reason: resolved
-
August 3rd, 2011, 08:33 AM
#2
Re: Need to Check for a particular string
IIRC you can treat a pre-existing BSTR just like an LPCWSTR. (Or as an LPWSTR if you want to modify it, but never change its length that way!)
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
August 3rd, 2011, 09:04 AM
#3
Re: Need to Check for a particular string
i am a noob in vc++.. can you please elaborate it further.
regards.
-
August 3rd, 2011, 09:09 AM
#4
Re: Need to Check for a particular string
-
August 3rd, 2011, 09:54 AM
#5
Re: Need to Check for a particular string
content is of type BSTR... that will hold some text like "Waiting for free XE Slot" or "Successfully completed".
-
August 3rd, 2011, 10:03 AM
#6
Re: Need to Check for a particular string
You can use the wcscmp() function to compare the two strings. It returns 0 if they are equal:
Code:
if (!wcscmp(content, L"Waiting for free XE Slot")) {
// The strings match!
}
And, to clarify that in advance, note that this test only passes if the two strings are exactly identical.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
August 3rd, 2011, 02:55 PM
#7
Re: Need to Check for a particular string
Originally Posted by Eri523
You can use the wcscmp() function to compare the two strings. It returns 0 if they are equal:
Code:
if (!wcscmp(content, L"Waiting for free XE Slot")) {
// The strings match!
}
And, to clarify that in advance, note that this test only passes if the two strings are exactly identical.
wcsstr?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
August 3rd, 2011, 05:10 PM
#8
Re: Need to Check for a particular string
Originally Posted by VladimirF
Yes, of couse, as an option for the case that an exact match is not required. And as I interpreted the OP, it is. The closing sentence of my post was just to make sure wcscmp() is not the function of choice in case an exact match is not required.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
August 3rd, 2011, 10:22 PM
#9
Re: Need to Check for a particular string
actually my content will hold some extra text too...like "'Extraction ID: EBS_XE_1265635755_3326
Waiting for next XE free slot (20)
". out of which i need to match just the "Waiting for free XE Slot".
it is somewhat i need to do a pattern matching what we do in Oracle. My content will hold a longer text. of which I need to match for whether that text has "Waiting for free XE Slot" as a part of it or not...
How can i achieve this..??
Last edited by p_zshk; August 3rd, 2011 at 10:28 PM.
-
August 3rd, 2011, 11:09 PM
#10
Re: Need to Check for a particular string
In this case VladimirF had the right instinct () and the function he suggested (and linked to its MSDN documentaion) is exactly what you need. It will return a pointer to the found partial string or NULL if it wasn't found. You're not actually interested in the location of the search hit, so check whether the return value is != NULL. If it is, the string you probed for is contained in the string you checked.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
August 4th, 2011, 10:07 PM
#11
Re: Need to Check for a particular string
thanks...Eric and Vladimir...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|