Striig Compare noode

Hi, how can I compare two strings in BP? I know there is an operators nodes == and != but where is >, => and <, =< ? I found this FString::Compare | Unreal Engine Documentation but i can’t see any node in BP. Can someone give me a clue to handle with sorting alphabetical order array of strings without < and > ? Any methods maybe I couldn’t find? Thanks!

Look for those in TEXT. Also there is Palette tab (you may need to turn it on from view/window menu on top). Palette shows all nodes, unlike that right click context list.
You can also disable context sorting in that right click dropdown list.

Btw Epic chated a bit with this dropdown list, that checkbox swaps between 2 list really, so you never know if you are missing nodes.
Best example for this is getting actor location, sometimes you get it from right click list sometimes it is only in palette (depends on node you drag from).
So always check PALETTE to see if node you want exists, then use dropdown list when you know it is there.

I checked it and there is no node like this. Im using 4.9.2

There are comparison nodes for ==, but none for > or < AFAIK. Out of the box, blueprints do not have any way to alphabetize an array, so you’d need to make a function/macro to do that for you, or just make your own comparison macros.

Yup i just checked in blueprint, there is not greater or less comparison for strings or texts, which is really weird.
Making those as macro in blueprints then using that in sorting algorithm will be very inefficient, that sorting begs for C++.

Well < and > are math functions so they shouldn’t work on text anyway. You have == or != for string’s which is common standard for string comparison, any other rules that you want to be in place would require breaking down the string.

The < and > operators work on strings in C++.

It would be possible to create a custom node which exposes that functionality to blueprints.

For example:

CompareStrings.h


#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "CompareStrings.generated.h"



UCLASS()
class PROJECTNAME_API UCompareStrings : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	
public:

	UFUNCTION(BlueprintPure, meta = (DisplayName = "String > String", CompactNodeTitle = ">", Keywords = "Compare String Greater"), Category = Game)
		static bool SGreaterThan(FString StringA, FString StringB);

	UFUNCTION(BlueprintPure, meta = (DisplayName = "String < String", CompactNodeTitle = "<", Keywords = "Compare String Less"), Category = Game)
		static bool SLessThan(FString StringA, FString StringB);
	
};

CompareStrings.cpp


#include "ProjectName.h"
#include "CompareStrings.h"





bool UCompareStrings::SGreaterThan(FString StringA, FString StringB)
{
		return (FCString::Strcmp(*StringA, *StringB) > 0);	
}


bool UCompareStrings::SLessThan(FString StringA, FString StringB)
{
		return (FCString::Strcmp(*StringA, *StringB) < 0);
}

rcKVxTB.png

3 Likes