Help with formatting text and removing empty strings

Hello, basically i want to input different strings/values into my text box and have it remove any empty strings so that there are no spaces/gaps between the text. I tried to find different ways to go about the text but i feel like the format text should work I’m just not sure if its possible to remove the empty strings.

This is what it shows with my current setup.
image

Btw its going to be using the different values from a data table i have so all the pins are going to be connected. i know how to do a check to see if its empty/null i just need to know how or if i can remove it from the format text node if it is empty or if i need to go about it another way.

thanks for the help.

Use String Replace

Format text → to String → String Replace → print

Delimit your data [ {data}, {data}, {data} ]. Last value doesn’t get a delimiter.

First replace pass replaces double delimiters with singles. Second pass removes the single and replaces with new line.

1 Like

Even though this is not on topic, do note you’re doing it all 60 per second, every frame, non-stop. Wouldn’t it be better to have 1 widget per line of text, neatly stacked in a vertical box and update it only once? You could collapse / style widgets at a whim, too… Rather than faffing around with strings, you could simply opt out out of showing specific widgets.

1 Like

Just so i understand, i would basically have 1 text widget for each stat in a vertical box and then collapse the widget if its empty? That makes sense, i wasn’t sure about creating multiple widgets because i didn’t know how to remove the empty widgets and reorganize the widgets that were left.

But how do i update it once? i thought with my setup already it would get called once when its created. or am i supposed to do it when it in the event construct?

Thank you

You’re using Get Text - I am assuming it’s widget property / function binding which executes once per frame:

image

I’d make 1 user widget per stat line. This way widgets can collapse themselves when they receive null text. Update it once (or whenever you desire) with a custom event call:

This can be taken further, ofc. Additionally, you can expose variables and populate user widgets’ data in the parent’s Designer. As in:

  • if this is the widget that represent a stat line:

image

  • its parent keeps a bunch of them in a vertical box and you label them:

The custom event inside the stat line should only update what is needed - the value.

1 Like

Ah thank you i appreciate the examples. No wonder your the community hero. :smiley: