File Exchange

image thumbnail

tprintf -- Print to Second Terminal Window

version 1.6.0.0 (4.64 KB) by Petorr
Print lines of text in secondary windows resembling command window.

0 Downloads

Updated 08 Aug 2014

View License

Terminal Print
c = tprintf( FigureName, Text );
Example:
tprintf( 'MyMessages', 'Hello world in 2nd terminal!' );
sends text 'Hello world in 2nd terminal!' to a window with the name MyMessages.
Clear the window: call without 2nd argument:
tprintf( FigureName );

Create window if it does not exist:

tprintf( FigureName , '' );

Requires external function findjobj(), provided by Yair Altman online from Matlab File Exchange

Peter Adany 2014

Comments and Ratings (5)

Petorr

I had no idea there were so many preexisting similar functions.

See jprintf:

mathworks.com/matlabcentral/fileexchange/8641-jprintf

Mine (tprintf) is quite simple, with one main file and one external dependency. I can attest I never knew of other ?printf functions out there when I made this. I hope everyone finds the one they like.

Petorr

@Jan

Thanks for another good suggestion with the non-integer figure handles.

Re: hiding the unwanted axis, now that you've mentioned the problem doesn't exist, I can't seem to recreate it. Now there's some voodoo if you ask me...

Jan

If you open the figure with 'IntegerHandle' set to 'off', the figure get a unique handle which is guaranteed not to collide with a user defined figure.

An axes appears "magically" in a new figure only, when a plotting command is called. But creating an invisible axes object is not useful to prevent this. So this is a kind of voodoo. ;-)

Petorr

Jan,

I used the setdiff(...) code to find an unused figure number >= 1000 which will be somewhat out of the way of the user.

Thanks for the suggestion to use findobj. I now use findobj to find the figure and text handles.

When creating a figure, sometimes a default axis is created and sometimes it appears later. That's why I create and hide an axis manually for new figures.

Thanks for your comments! - Peter

Jan

I do not understand the sense of
fH = min( setdiff(1000:10000,fHs) );
when fH is overwritte later.
What about this simple code to obtain the handle of the figure:
fH = findobj(allchild(0), 'flat', 'Name', figureName)

The axes aH is not used anywhere. So why do you create it?

You have the handle of the UICONTROL sH allready. Why do you obtain it by a loop and comparing the type of the figure's children? It would be cleaner to call either FINDOBJ instead of a loop, or to store the handle in teh figure's ApplicationData (see GUIHANDLE).

Updates

1.6.0.0

minor update; no features altered

1.5.0.0

Removed %# from comments because they were causing pragma warnings.

1.4.0.0

Code clarity / minor adjustments

1.3.0.0

Minor improvements & code cleanup.

1.2.0.0

14317 acknowledgement

1.1.0.0

Added ability to clear the window by calling without 2nd argument.

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux