TXCD
                                    ====

                          Code and decode a string


These two complimentary commands are used for parsing strings; converting
coded strings to readable txt (CD2TX$) or, using a special syntax,
converting character strings into their coded equivalents.


Usage:
------

CD2TX$

        text$  = CD2TX$([#channel,] code$ [,base%])

Converts coded ASCII into human-readable form, all unprintable characters
converted into lists of comma-delimited <base> bytes, and all alpha-numeric,
or printable characters quoted:

eg

        CHR$(16) & CHR$(65) & CHR$(66) & CHR$(67) & CHR$(34)

is converted into the string

        $10,"ABC",'"'

base may be 10 = decimal, or 16 = hexadecimal. Default is hex.

Since different fonts contain different ranges of printable characters an
optional channel number may be given and the range of that font will be used.

The default channel is #0

If channel is invalid (closed or not a console) the default is 32..191, but
no error is returned.


TX2CD$

        ascii$ = TX2CD$(string$ [,erpos%])

where string$ is of the form:

 item      = string | code [delimiter + item]*

 string    = [<start quote>] + ascii characters + [<end quote>]

 code      = $ + $digit [$digit] | % + %digit [%digit]*7 | digit [digit]*2

 quote     = "'" | '"' AND <start quote> = <end quote>

 delimiter = , | <SPACE> | <end-of-string>

 $digit    = {0..9,A..F,a..f}

 %digit    = {0..1}

 digit     = {0..9}

and

 erpos%    =  if provided and int, returns 0 or a number between 1 and
              len(string$) to indicate where in the input string an error
              was found . The parsed string is returned up to the point
              of error.

eg:

        "abc",$10 %10101 "r""s" "t"u, ,x  ,12,'"'

in bytes equals

        97,98,99,16,21,114,115,116,117,120,32,32,12,34

Note that <SPACE> is treated as a space inside unquoted strings and as a
delimeter outside them.


Program status:
---------------

V0.01, ©PWITTE October 15th 1995
V0.02, June 23rd 2000
V0.03, pjw, May 28th 2019, modularised, simplified putp

               Conditions of use and DISCLAIMER as per Knoware.no