Larraz
(Larraz)
May 21, 2014, 11:48am
1
Hi, i want to know how can i draw using canvas or using Debug Message to show a String line char by char.
I know how can i get it using GetCharArray() or using Text[0] but i dont know how to print it because i dont know how to cast TCHAR to FString
Thanks
Dune
(Dune)
May 21, 2014, 3:21pm
2
FString output = “SomeString”;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, *(output));
That gives a debug message of a string. You can attach ints to the string as well or append chars.
Rama
(Rama)
May 21, 2014, 10:54pm
3
“because i dont know how to cast TCHAR to FString”
#Converting a single TCHAR to FStirng
Here’s how I’ve succesfully converting a single TCHAR to an FString
FString MyChar("" + 'c');
do this in a loop if you really want FStrings for each char of an original FString.
however,
#Most Functions what TCHAR* , not FString
#UE LOG
TCHAR c = 'c';
UE_LOG(SolusLog,Warning,TEXT("Single Char: %s"), c);
#OnScreenMessage
TCHAR c = 'c';
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s"), c));
I think FString constructor accept TCHAR, fstring(“something”)
Rama
(Rama)
May 22, 2014, 12:09am
5
#I forgot the FPrintf
Sorry, this will work now!
TCHAR c = 'c';
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s"), c));
Larraz
(Larraz)
May 22, 2014, 12:06am
6
OnScreenMessage just supports FString, and if i do this FString MyChar("" + ‘c’);, shows an n instead of a c.
Just i want to do its this
FString Hi = “Hi there”;
TArray t = Hi.GetCharArray();
for (int i = 0; i < t.Num(); i++)
{
TCHAR c = t[i];
// Here prints the char on screen
}
Larraz
(Larraz)
May 22, 2014, 12:09am
7
This just show on screen SomeString, that i want to do its show a char of the String (for example if i want to print the ‘e’ , its the 4 position of the string
Larraz
(Larraz)
May 22, 2014, 9:13pm
8
Thanks dude, it works!!! I dont knot that its possible to use Printf hehe
But there is a little mistake, you are using %s , that is for print strings, and we are using a type of char so it should bt %c instead
Rama
(Rama)
May 22, 2014, 10:24pm
9
#Resolved
Great!
I am glad you got this figured out now! I will remember %c for the future
(if you can, check mark my answer this post if your issue is resolved)
Dune
(Dune)
May 23, 2014, 9:01am
10
FString is basically a character array anyway. You could always:
FString theString = "SomeString";
FString output;
output.AppendChar(theString[3]);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, *output);