Technical article 104874

Is it possible to take an ASCII screen dump of a Vtcl(TCL) based program?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6

Written · Last revised

Problem

I would like to illustrate an example of using a vtcl(TCL)-based
program in an ASCII document.  Is it possible to do this?

Solution

A program using vtcl(TCL) can be run in curses(S) (character) mode, by unsetting the DISPLAY environment variable. To capture the screen output, use a scoterm(XC) emulator, and unset the DISPLAY environment variable, eg (in ksh(C) or sh(C)):

$ unset DISPLAY
The vtcl(TCL) program can now be run in the scoterm(XC), and
will use the curses(S) based display engine rather than the
Motif engine.  Select the screen display you wish to capture
and cut-and-paste the screen to a file using the mouse.

This may simply be achieved using vi(C) in another scoterm(XC). Start vi(C) and enter insert mode, for example:

$ vi /tmp/output_file
<i>

After you cut-and-paste the screen shot into the file, enter <Esc> to return to command-mode in vi(C), and save the file.

The file (however created) will contain ANSI line-drawing
characters, which will not display correctly in an ASCII
document.  A simple script is appended which will convert
simple ANSI line-drawing characters to pipe symbols '|',
hyphens '-' and equals symbols '='.

Run the attached script on the file and redirect the output to a new file:

$ convertVtclCurses /tmp/output_file > /tmp/image.ASCII
NOTE: The script, as shown, can only translate simple line-drawing
characters; no attempt is made for those which cannot be
represented using the characters noted above.  This translation
is, however, effective for the majority of vtcl(TCL) screen output.
The screen thus translated may be 80 characters wide.  It may
be useful to trim the width of the line to 78/79 characters by
removing an extraneous character from each line.

If the output from convertVtclCurses still includes ANSI line-drawing characters, the od(C) command may be used to determine the octal values of such characters, for example:

$ convertVtclCurses file.ansi | od -c

Add the octal values to the tr(C) command with an appropriate ASCII translation.

#!/bin/ksh
#
# simple translation of scoterm(XC) line drawing characters to it(SSL) format
#       __      __      __
#       |                |              |       -       |
#
#       |                |      ==>     |               |
#
#       |                |              |       -       |
#       --      --      --
if [ $# -lt 1 ]
then
        echo "convertVtclCurses file [ file file ... ] [ > output ]"
else
        while [ $# -gt 0 ]
        do
#
#       The complete list of translated (octal) characters is:
#       \332 \304 \277 \263 \300 \267 \331 \272 \324 \315 \274 \270 \273 \275
#       \276 \310 \311 \323 \325 \326 \260
#
#       to (ASCII) '|-|||||||=||||||||||#'
#
#
                cat $1 | tr
'\332\304\277\263\300\267\331\272\324\315\274\270\273\275\276\310\311\323\325\32
6\260' '|-|||||||=||||||||||#'
                shift
        done
fi

From the Xinuos technical article database, record 104874. Reproduced with permission. The original is at www.sco.com/ta/104874, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.