0

Hi,

I Have a CString (MFC) which contains the following three conditions separated as follows.

Message=("Condition1|Condition2|Condition3")

I am trying to extract the three conditions from the CString and use them to perform other operations. However I cant seem to find the right built-in function.

Could someone please advise on what the best way to do this will be? Cant seem to find a function which can strip away to the left and right of the "|" operator.

Thanks in advance.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by MrSpigot
0

CString has Left(), Right(), and Mid() methods which are something like std::string's substr() method.

Edited by Ancient Dragon: n/a

0

I've always found AfxExtractSubString() to be useful for that kind of thing. Not a particularly well documented function but it's there and it works.

BOOL AFXAPI AfxExtractSubString (
   CString& rString,
   LPCTSTR lpszFullString,
   int iSubString,
   TCHAR chSep = '\n'
);

e.g.
set lpszFullString to "Condition1|condition2|Condition3",
set chSep to '|'
set iSubString to 0,1 or 2
and you'll get rString returned as "Condition1", "Condition2", or "Condition3".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.