aboutsummaryrefslogtreecommitdiff
path: root/cxrefbas.rst
blob: 70042170ed37edc546d2953a63d411b28bc94305 (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
========
cxrefbas
========

----------------------------------------------------------
Code cross-reference for tokenized Atari 8-bit BASIC files
----------------------------------------------------------

.. include:: manhdr.rst

SYNOPSIS
========

cxrefbas [**-v**] **input-file**

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

**cxrefbas** reads an Atari 8-bit BASIC tokenized program. For each
line number in the program, it prints a list of lines that reference
it.

**input-file** must be a tokenized (SAVEd) Atari BASIC program. Use
*-* to read from standard input, but **cxrefbas** will refuse to read
from standard input if it's a terminal.

Each line number reference in the output is followed by a letter that
indicates the type of reference:

**G**
  *GOTO* (without *ON*) or *GO TO*.

**S**
  *GOSUB* (without *ON*).

**I**
  *IF* with line number only, e.g. *IF X THEN 1000*.

**O**
  *ON/GOTO* or *ON/GOSUB*.

**R**
  *RESTORE*.

**T**
  *TRAP*.

**L**
  *LIST*. It's very rare for a program to *LIST* parts of itself, but
  it's allowed by BASIC so it's supported here.

If a line doesn't exist, but is referenced (e.g. *GOTO 100*, but there
is no line 100), it's printed in the table, prefixed with *!*.

Any command that uses a computed value for a line number will print a
warning on standard error, e.g. *GOTO A* or *GOSUB 100\*A*. Even *GOTO
100+0* is a computed value, since BASIC doesn't do constant folding.

Line numbers above 32767, e.g. *TRAP 40000*, are not listed.

Atari BASIC allows fractional line numbers, such as *GOTO 123.4*.
These are rounded to the nearest integer when the program is
executed. **cxrefbas** handles these correctly, although you're
not likely to run into them in real-world programs.

OPTIONS
=======

There are no application-specific options.

.. include:: genopts.rst

EXAMPLE
=======

This program::

  10 GOSUB 100:GOSUB 200
  100 RESTORE 1000:IF A THEN 120
  110 GOTO 200
  120 ON B GOTO 300,310,320
  200 RETURN
  300 PRINT 1
  310 PRINT 2
  1000 DATA XYZ

Produces this output::

  100: 10:S 
  120: 100:I 
  200: 10:S 110:G 
  300: 120:O 
  310: 120:O 
  !320: 120:O 
  1000: 100:R 

Note that line 320 doesn't exist in the program, so it's shown with
*!* in the output. Line 120 has *100:I*; if the *THEN 120* were
changed to *THEN GOTO 120*, line 120 would read *100:G*.

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

0 for success, 1 for failure.

.. include:: manftr.rst