XREF

XREF

Supported On UX WS DOS
Option Required XREF
Keyboard Executable Yes
Programmable No
In an IF ... THEN ... No

XREF produces a cross-referenced listing of the identifiers in a program or subprogram.

Example Statements

XREF
XREF #PRT
XREF #701;FNUser$
XREF MAIN:NV

Item Description Range
device selector numeric expression; rounded to an integer Default
PRINTER IS device (see Glossary)
subprogram name name of a SUB subprogram currently in memory any valid name
function name name of a user-defined function currently in memory any valid name

Semantics

The cross-reference listing is printed one context at a time, in the order that they occur in the program. The main program is listed first, followed by the subprograms.

The cross-reference listing starts with this line:

        >>>> Cross Reference <<<<

Before each subsequent program segment, this line is printed:

        >>>> Subprogram <<<<

followed by the line number of the first line in that context and the name of the context. If the subprogram is a user-defined function, an FN will precede the name, and if it is a string function, a $ will follow its name.

Within each context, identifiers are listed by type. They occur in the following order:

If a type is specified in the command, only that type is printed. If there are no identifiers of a particular type in the context being cross-referenced, that heading is not printed.

Within each group (which is composed of a header telling what kind of !entity follows, then the list of those entities), names are alphabetized according to the ASCII collating sequence, and line numbers are in numerical order. If a reference is a formal parameter in a SUB or DEF FN statement, declared in a COM, DIM, REAL, or INTEGER statement, or is a line label, the characters <-DEF will be printed immediately to the right of the line number containing the defining declaration. Note that variables declared by ALLOCATE are not given this marker. If unlabeled (blank) COM is used, it will have no name associated with it.

At the end of each context, a line is printed that begins with:

Unused entries =

This is a count of the symbol table entries which have been marked by a prerun as "unused." Unreferenced symbol table locations which have not yet been marked "unused" by the prerun processing will show up in the lists of identifiers with empty reference lists. Note that a subprogram that is not directly recursive will show up in its own cross-reference listing with an empty reference list. (See the "Debugging Programs" chapter of  HP BASIC Programming Guide for further details.)

If a subprogram name or MAIN is specified in the XREF command, the above rules are followed, but only the specified subprogram or the MAIN program is cross-referenced. If there are two or more subprograms of the same name in the computer, they will all be cross-referenced.

An XREF can be aborted by pressing [RESET], [CLR I/O] or [Break].