Set button text from CSV. Works, but is very ugly. Can I make this less horrible?

Purpose: Look through a CSV, find the “key” in the row, and use the text in the next column to change the text of a button. IE, I hand it the number “4”, it will find row “4” and grab the text, and then I’ll change the text on a button to be that text.

This code works, but looking at it makes me want to die. Please tell me I’m doing something overly complicated and that I don’t need to convert FText from String from FName from Fstring from Int

responseFullText1 = FText::FromString(((dialogCSV->FindRow (FName((FString::FromInt(key))), TEXT("")))).chatText);

1 Like

Ha that’s pretty awful. But yeah it takes FNames and I’m not sure what order GetAllRows will give you, so I reckon you’re stuck with that.

This is sad news

Well your first step is to use some intermediate variables. The code looks bad because you’ve nested about a million functions. Split it up and add some comments to make it more readable and, crucially, debuggable.