List

From BR Wiki
Jump to navigation Jump to search


This article discusses the List command. For the List GUI see Grid and List.


The List (LIS) command searches for and displays some or all of the program lines according to one or more of the following options:

  1. A specific range of line references,
  2. The presence or absence of specific case-insensitive strings,
  3. The presence or absence of specific case-sensitive strings.

The string search capability of the LIST command additionally allows for string replacement.

LIST supports two additional parameters: SKIP and -p. When used with LIST PRINT, SKIP will prevent the form feed from occurring at the end of printing. The -p parameter will output one line at a time when LIST is used to search for or replace a program string.

Comments and Examples

LIST will display lines on the screen, print them out on a printer, or save them as a new file. Scrolling to lines above and below the screen display is allowed with the up and down arrow keys as well as with the PgUp and PgDn keys. The ability to scroll beyond the displayed lines can be discontinued by pressing the period (.) key immediately prior to pressing an up or down arrow key.

The following example lists a full screen of program lines up to and including line 350:

LIST -350

The next line prints all of the lines from 350 to the end of the program:

LIST 350- PRINT

The following example sends lines 500-1350 to the file OUTPUT.BRS, which gets created by this command on the disk in drive B:

LIST 500 1350 >B:\OUTPUT.BRS

The next example lists all program lines containing the two strings "OPEN" and "DISPLAY", but not containing the string 'srow'. Note that single quotation marks have a different meaning than double quotation marks with the LIST command: single quotation marks indicate that uppercase or lowercase matches are to be accepted, while double quotes indicate that only an exact case match should be accepted.

LIST "OPEN" "DISPLAY" ~'srow'

The following example shows the use of input file redirection with the LIST command:

LIST <PROGNAME.BR 5000,6000
LIST <PROGNAME.BR "OPEN"
LIST <PROGNAME.BR >TEMP.BRS

The input file option is also very useful in automating conversions between different major releases of BR. LIST <PROGNAME.BR extracts the source code from PROGNAME.BR regardless of which version or release of BR was used to create the file. Thus, the following command can read files and send the listing to the source file TEMP.BRS:

LIST <PROGNAME >TEMP.BRS

The REPLACE parameter allows one string to be replaced with another. The following example causes all lines from line 60 to line 300 to be searched for the string '2,40,C 20,R'. Each line with a match will be displayed on the screen with "3,42,C 30,R" replacing the matching string. To make the displayed lines permanent, you must scroll down and press <ENTER> on each line to be kept. Another alternative is to redirect the lines to a file and then use the PROC command to enter them in.

LIST 60 300 '2,409,C 20,R' REPLACE "3,42,C 30,R"

Syntax

LIST [ [-]<line number>[-] ] [< <input file>] [<line number> [<line number>] [{~"<string>"|~'<string>'|"<string>"|'<string>'}][...3x] [REPLACE "<string>"] [ CLAUSES ] {[>[>]<output file>]|[PRINT]}

Defaults

  1. List from current file.
  2. List all lines if applicable.
  3. List only the line indicated if applicable.
  4. List all lines specified.
  5. List lines that contain the specified string.
  6. Send output to the screen.

Parameters

The word clause may be added to a list command to add identifiers as to where each clause begins and ends in each line listed.

The LIST command requires no parameters. If you type LIST and press <ENTER>, the system will scroll through all of the program lines in memory.

There are two main paths through the syntax diagram. The top path allows you to list a full screen of program lines that either start or end with the specified line number. The line number may be either a line number or a line label. Use a dash (-), either before or after a line reference, to view the specified line and a screen of lines above or below it.

The bottom path through the diagram provides you with several alternatives.

The redirected input file parameter may be used with the LIST command instead of a program loaded in memory.

LIST <SOMEPROGRAM.BR "INVOICE"

The from line number parameter allows listing of lines from any .BR file. The program in memory is unchanged by input file redirection.

The from line number and to line number parameters specify the starting and ending line numbers or labels from which lines should be displayed.

From this point, there are three options.

The top option allows you to specify up to three "string" parameters. BR will display all lines which either do or do not contain the specified string according to whether the not operator ~ is used. Any combination of strings with or without the not operator may be specified. Single quotes represent case insensitive while double quotes represent case sensitive matching.

The middle option allows you to specify a search and replace operation. The quotation marks and "string" parameter operate in the same manner described above. The REPLACE keyword and the string that is to replace the current string must follow. BR will locate all lines that contain a match, replace the specified strings and display the new lines. The lines will not become permanent unless you scroll back up to each one and enter it by pressing <ENTER>.

The bottom option is the default. When no strings are specified, BR lists all specified lines.

>Redirected output File saves directory information that would normally be displayed on the screen to a text file. >>Redirected output File appends directory information to an existing text file.

PRINT redirects output to a printer. It is important to note that the redirected output differs from the screen output: whereas the screen displays just one line when a single line number is indicated, PRINT prints all lines from the start of a specified program to the end of the program.

LIST PRINT now utilizes printer initialization escape sequences.

LIST -P now works under a broader range of conditions, including input redirection.

LIST <TEMP -P

When the LIST command's -P parameter is used, a digit (1-9) is now accepted from the keyboard after the first scroll (and on subsequent scrolls) to identify the number of additional lines to scroll. Pressing <ENTER> still causes a single line to scroll.

LIST with a single line number and redirection to a file name now causes only the specified line to be redirected. Previously all lines from the line specified to the end of the program were redirected. This change could affect existing applications.

Technical Considerations

  1. LIST with the >Redirected output File option is a useful way to record changes made to a program while it is in execution. Simply make the change, press <ENTER> to enter it, then list the changed line or program to a file. To use the newly saved file as a program, LOAD it from source.
  2. The ability to scroll beyond the displayed lines can be discontinued by pressing the period (.) key immediately prior to pressing an up or down arrow key.