Odd text formatting - carriage return with no obvious reason

Edit: .toe shared

I am putting together a couple strings in a text.TOP and I am getting a carriage return for no obvious reason. My f-string should be good but I am getting this weird two line output…

Any ideas?


TextFormatting.toe (3.7 KB)

I figured out how to get it to format the way I want…

I have CHOPtoDATs linked to my CHOPs.

I was linking the text from the CHOPtoDATs and for some reason that was breaking things.

If I link the text from COMP channel data directly it doesn’t break.

How would you use the CHOPtoDAT data for this and not break things?

Thanks!!

Look into the CHOP value replace option, if I’m correctly understanding what you’re trying to do I believe that will help.

You probably have a blank line at the end of the first text op.

There is no text op. I am pulling from CHOPtoDAT ops.

Here’s an example. Why are they different?

TextFormatting.toe (3.7 KB)

“CHOP value replace option” Where do I find this?

It’s a parameter on the text TOP

1 Like

str(op('chopto1')[0,0]) +" "+ str(op('chopto2')[0,0])
1 Like

and here’s another way to do it too, if you’d like to use nodes instead of expression:

The Concatenate with field just has a space in it

1 Like

I don’t understand why that works but the F-string does not. Why is it not following the format of the f-string?

I appreciate the info but I don’t want to just know how to fix it, I want to know why/what happened/what’s going on.

It works with f-string too, just pull [0,0] instead of .text (since it’s a table):

I guess .text on a table adds a blank line. That’s why your original output is also vertically moved up, because it’s adding a line break after both strings. You called it a “weird two line output”, but it’s actually three :slight_smile:

1 Like

You’re right, its 3. I was wondering why it was shifted up from center, too.

Is adding the blank line something that is supposed to happen/expected/normal?

Between this and trying to figure out how to zero pad the numbers has driven me crazy all day. In Python I’d set a variable and then .zfill() the variable but I have no idea how to do that in Touch with real time data. Its always a learning adventure!

Thanks for the help!

Not sure, but documentation says:
image

Why it’s doing it to a table that only contains one row, I couldn’t tell ya. I always just use the cell (ie. [0,0]) instead of the whole table.

For 0 padding, you can try adding .zfill() after the str()

1 Like

Interesting that it pulls the tabs or what ever is causing it out with the .text. I usually use cell coordinates but for some reason I went with .text this time. Probably trying to trouble shoot some bad code and swapped it just to test. Maybe? I don’t know. But you fixed it. TY

And thank you for the zfill hint. I’ll give that a shot. Much easier than the method I’ve been toying with the last few hours.

You’ve made my day today!

1 Like

Just an aside. str(op(‘chopto1’)[0,0]) correctly converts the data in a cell to a string by casting (Derivative programmed str() to do that). More simply op(‘chopto1’)[0,0].val IS the string part of the cell, so no str() casting is needed, and it’s a bit more clear what it is.

A table cell is a python object that includes members .val and other info about itself: Cell Class - Derivative. It took me a while to appreciate that a cell isn’t just a string but is more than that.

Thanks for the tip. I’ll update my code.