aboutsummaryrefslogtreecommitdiff
path: root/listbas.rst
blob: 881da5f1ae6afa23825cb54e8b4c1486294ae376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
=======
listbas
=======

--------------------------------------------------------
List the source of a tokenized Atari 8-bit BASIC program
--------------------------------------------------------

.. include:: manhdr.rst

SYNOPSIS
========

listbas [**-v**] [**-i**] [**-a** | **-m** ] **input-file**

DESCRIPTION
===========

**listbas** acts like the *LIST* command in BASIC. It reads a
tokenized (SAVEd) BASIC program and prints the code in human-readable
format.

By default, output is Unicode in UTF-8 encoding, with ANSI/VT220
escape sequences for inverse video and color syntax highlighting.

OPTIONS
=======

List options
------------

**-a**
  Output raw ATASCII; no translation to the host character set. Must be
  used with redirection; **listbas** will not write ATASCII to the terminal.

**-b**
  Use bold, for color output. This may make it easier to read on
  some terminals. Or, it may hurt your eyes...

**-i**
  Include the immediate mode command (line 32768) in the output.

**-m**
  Output "magazine listing". See the **-m** option for **a8cat** for details.

**-n**
  No color. Has no effect if **-a** or **-m** are in effect, since these
  modes don't support color anyway.

.. include:: genopts.rst

COLORS
======

Color output only works on terminal emulators (or real terminals)
that support ANSI/VT220 style escape codes. This includes all modern
terminal emulators, and most not-so-modern ones in the UNIX world.

The color scheme is:

**yellow**
  Commands. Also "command operators" such as the **GOTO** in **ON/GOTO** and
  the **STEP** in a **FOR** command. These are really operators as far as
  BASIC is concerned, but it makes more sense to colorize them as commands.

**green**
  Operators (except functions and "command operators").

**purple**
  Functions.

**red**
  Numbers (except line numbers at the start of a line) and string
  constants.

**cyan**
  Line numbers at the start of a line, comments (**REM** text) and **DATA** elements.

Variable names and commas between **DATA** elements are not highlighted,
so they'll appear in the default foreground color (usually white if the
terminal has a black background, or black if the background is white).

Note that nothing is highlighted in blue. This is because it's
difficult to read on many terminals. Also, black and white are not
used because presumably, one or the other is the background color of
the terminal.

NOTES
=====

**listbas** will refuse to operate on a LIST-protected program with
scrambled variable names. For code-protected programs, it will stop at
the line with the invalid offset. Use **unprotbas**\(1) to remove the
protection.

**listbas** is similar to Jindroush's **chkbas**\(1). The main differences are:

- **listbas** prints ATASCII graphics as Unicode equivalents, so the listing
  looks very similar to how it would appear on the Atari.

- **listbas** does color syntax highlighting.

- **listbas** only supports Atari BASIC, not Turbo BASIC or BASIC XL/XE.

- **listbas** doesn't show information about the variables. Use **vxrefbas**\(1)
  for that.

- **listbas** will not write ATASCII data to your terminal. By default, it uses
  **a8cat**\(1) to convert the output to something human-readable
  that won't confuse the terminal. When outputting raw ATASCII (**-a** option),
  it refuses to run if standard output is a terminal.

- **listbas** only lists line 32768 (the immediate mode command) if
  specifically asked to do so.

- **listbas** doesn't print a banner on startup.

- **listbas** tells you if the program is protected, and refuses to operate
  on variable-protected programs.

I thought about adding an HTML output option, but there's no need: if you want
a colorful listing of an Atari BASIC program, install **aha**\(1) from
https://github.com/theZiz/aha (or your distro's package repo) and run
something like::

  listbas PROGRAM.BAS | aha > program.html

EXIT STATUS
===========

0 for success, 1 if there was an error reading the input (e.g. file
not found), or 2 if the input file has invalid tokens (if this
happens, you will also see a warning about it on stderr).

.. include:: manftr.rst