How to compare a FString in C++ Condition Breakpoints?

I have some FString variable needs to be compared and I want to use condition breakpoints to debug. I know in regular C++, i can just use ’ strcmp( newString._Bx._Buf, “my value”)==0 '. But here is FString. And i try to use some different combinations of several functions, like FString::Equals(…), …

You should be able to use the == operator to make a comparison. Since you mention the Equals() method, you may have already read that and the above, but just in case:


Comparisons

The overloaded == operator can be used to compare two FStrings, or to compare an FString to an array of TCHAR*s. There is also the FString::Equals() method, which takes the FString to test against and the ESearchCase enum for whether or not the comparison should ignore case as arguments. If you want the comparison to ignore case, use ESearchCase::IgnoreCase, and if not, use ESearchCase::CaseSensitive.

TestHUDString.Equals(TEXT("Test"), ESearchCase::CaseSensitive);

Information on comparisons, conversions, etc for FString and related types, including the above, can be found here. Did neither of these methods work?

Hi,

You should be able to do this in your conditional breakpoint. It’s not pretty, but it should work:

wcscmp((wchar_t*)MyString.Data.AllocatorInstance.Data,L"MyText") == 0

Hope this helps,

Steve

2 Likes

Some extra findings are that nearly all comparison requires the TEXT macro will not work in conditional breakpoint expression, as it is not recognized by IDE.

This works! Thank you

2 Likes