console in a texture? [ 099 component ]

Interesting exchange today on the slack channel about how you might approach getting the contents of the textport into a window for your output. I don’t know if there’s a direct way to access the contents of the textport, and I don’t think I’d actually want that. Instead you might write up a little method to help handle just those things.

In the provided example you can see how you might go about setting up an extension to smartly handle updating a table with a string as well as how to clean up that table, and make sure that the latest message still manages to get displayed.

I don’t know if it’s handy for anyone else, but figured that it was worth sharing even if it helped one person.
base_printDispExample.tox (2.92 KB)

For a more complete description see the doc strings in the extension.

Great component.
A tip that may or may not be useful here:
You can redirect stdout, stderr to any DAT you wish:

#you'll want to stash these somewhere
o = sys.stdout
e = sys.stderr
#point to a DAT
sys.stdout = op('/project1/text1')
sys.stderr = op('/project1/text1')

....print, generate errors, etc...

#restore
sys.stdout = o
sys.stderr = e

It doesn’t capture prompts or what you type, but maybe it should next.

1 Like

YOU’RE ROCKING MY WORLD ROB!

Nice one to share.

This is very cool, thanks for sharing. But the auto-scroll isn’t working for me. The parent().StartRow and parent().EndRow expressions don’t update until I toggle the Select DAT bypass off/on. I’m using version 2021.16124. This is easy to reproduce by simply importing the attached TOX in a fresh project and waiting 11 seconds for the text output to fill up.

Coming back to this, it seems that this will crash TD without a warning, just close and off you are.

Example component
textportotdat.tox (862 Bytes)

yep, same here.
stderr close TD and thats all

Sorry @alphamoonbase , how do you crash TD with this?

Hmmm, it seems to work on my laptop. I will have to check again next week when I am on my office PC. Will post specs then!

1 Like
  1. Enable sys.stderr
  2. open any text dat and write something (just text, not code)
  3. right click → run script
  4. TD closes without any messages

but if do this without stderr, console will popup error message like ‘variable not found’.