Search                        Top                                  Index
HELP OUTCHARITEM                                          Barrett et al, 1984

    outcharitem(<character_consumer>) -> <item_consumer>;
    outcharitem(discout<filename>) -> <item_consumer>;

OUTCHARITEM is applied to a character consumer and returns an item consumer,
which behaves exactly like *PR, except that instead of printing the characters
to the terminal via *CHAROUT, it feeds them to the specified character
consumer. Thus, using OUTCHARITEM, the user can direct output to a file and
the screen in the same procedure since *CUCHAROUT has not been redefined.

The procedure MIXOUTPUT outputs items to both the terminal and a file:

    define mixoutput(file);
        vars outchar outitem list1 list2;
        [this is list1] -> list1;
        [this is list2] -> list2;
        discout(file) -> outchar;           ;;; OUTCHAR is a character consumer
        outcharitem(outchar) -> outitem;    ;;; OUTITEM is an item consumer
        outitem(list1);                     ;;; output to the file
        pr('list1 is filed');             ;;; printed on the screen via CHAROUT
        pr(newline);
        outitem(list2);
        pr('list2 is filed');
        pr(newline);
        outitem(newline);
        outitem(termin);                    ;;; needed to close the file
    enddefine;

To call MIXOUTPUT, directing some output to the file called MIX, do:

    mixoutput('mix');
    list1 is filed
    list2 is filed

The file MIX contains:  [this is list1] [this is list2]

See also
HELP *CUCHAROUT  - holds the character consumer currently in use
HELP *DISCOUT    - creates a character consumer for a file or device
HELP *CHAROUT    - outputs a character to the terminal
HELP *PR         - a variable which holds a printing procedure
HELP *INCHARITEM - converts character repeater procedure into item repeater
REF *ITEMISE     - for more on itemisation of input
REF *SYSIO       - for details of I/O procedures
HELP *CHAROUT    - outputs a character to the terminal
HELP *PRINT      - for a list of files on printing procedures