## `TEXTWIDTH` -- the maximum number of characters in an output line

#### Introduction

The environment variable `TEXTWIDTH` determines the maximum number of characters in one line of screen output.

#### Call(s)

`TEXTWIDTH`
`TEXTWIDTH := n`

#### Parameters

`n` | - | a positive integer smaller than 2^31. The default value is 75.

#### Related Functions

`fprint`, `PRETTYPRINT`, `print`

#### Details

- Output is broken into several lines if it needs more than `TEXTWIDTH` characters per line.
- Deletion via the statement ```delete TEXTWIDTH`'' resets `TEXTWIDTH` to its default value. Executing the function `reset` also restores the default value.
- The minimal value of `TEXTWIDTH` depends on the length of the prompt string, which is defined via `Pref::promptString`: The minimal value is 7 plus the length of the prompt string. The default prompt string is `">> "`, thus the minimal value of `TEXTWIDTH` is 10 in this case.
- `TEXTWIDTH` is set to its maximum value 2^31 - 1 when printing to a text file using `fprint`. Thus, no additional line breaks occur in the output.
- `TEXTWIDTH` does not influence the typesetting of expressions which is available for some user interfaces of MuPAD.
- Most examples in this manual are printed with `TEXTWIDTH` set to 63.

#### Example 1

The maximal length of a line is set to 20 characters:

    >> oldTEXTWIDTH := TEXTWIDTH:
       TEXTWIDTH := 20: 30!

          2652528598121910586\
          36308480000000

We restore the previous value:

    >> TEXTWIDTH := oldTEXTWIDTH: 30!

                         265252859812191058636308480000000

#### Example 2

The following procedure adds empty characters to produce output that is flushed right:

    >> myprint := proc(x) local l; begin
                    if domtype(x) <> DOM_STRING then
                       x := expr2text(x);
                    end_if;
                    l := length(x);
                    print(Unquoted, _concat(" " $ TEXTWIDTH - l, x))
                  end_proc:

    >> myprint("hello world"):  myprint(30!):  myprint("bye bye"):

                                                              hello world

                                        265252859812191058636308480000000

                                                                  bye bye

    >> delete myprint:

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000