QW Scripting: ListAll
ListAll 1.02 September 7, 2000
ListAll is a script that searches for a string, a regular expression or a pattern
in the current file and, optionally, all
associated Include, Use or COBOL Copy library files. It contains the main
logic for searching files and uses the
FindAll document method.
ListUse and ListCopy scripts
On Command blocks which invoke a ListAll method (subroutine)
with appropriate parameters. This means these scripts will not work if ListAll has
not been previously loaded.
The search string can be a simple
string, a regular expression or a pattern. The appropriate string format is selected
using the corresponding entry point implemented using
The script is designed to be loaded.
It is distributed in the
autoload subdirectory of the Robelle
script library so it should load automatically. If it is not, you can load it manually
using the Manage scripts command of the Script menu.
The driver subroutine is called ProcessListRequest.
Information on Listlines is organized as follows:
The main subroutine is called ProcessListRequest and accepts 2 parameters.
- SearchType: This parameter is required.
It is an integer indicating which search option to use:
- is a String
- is a Regular Expression
- is a Pattern
- IncludeFile: This parameter is optional.
It is a string indicating whether or not to search referenced files.
If specified, this parameter can be blank, Include, Use or Copy.
The script is designed to be loaded. It can be invoked from the Script menu
or from any other script.
Running From the Script Menu
The scripts can be loaded manually. Their commands are added
to the Robelle command group of the
Script menu. The subcommand names are List All,
List Copy, List Include and List Use.
Each subcommand offers 4 different options:
- String: Search using a simple string
- Regexp: Search using a regular expression
- Pattern: Search using a pattern
- About...: Displays a brief explanation of the script's purposes
Running From Another Script
The following sample script provides an example that searches all $include files referred to
in the file
k.data on the connection Production MPE.
The search uses a simple string.
This sample script takes advantage of the
fact that the QSLUtilListAll script is distributed with Qedit
for Windows as a loadable script (in this case, already loaded):
file = open(connection: "Production MPE", filename: "k.data");
searchType = 1; -- Search for a string
scanInclude = "Include";
Execution Logic Overview
The ListAll script uses the same approach whether you use the menu command or invoke
it from another script.
- The script assumes the currently active document is the main source.
- If there is no active selection, the script prompts for a search string.
If a string is entered, it is used in subsequent steps.
- If the user chooses to search for a regular expression or a pattern,
the script always prompts for one. If there is an active selection,
the selection is used as the default search string.
- If there is an active selection and the user chooses to search for a simple
string, the script uses the selection as the search string.
- The script then calls the
FindAll document method. The method
returns the matching lines in a record variable.
- The script scans the record and inserts the lines in a new local file.
The ProcessListRequest subroutine displays informative messages in the log window
of the Script Control dialog box. These messages include the version number,
error messages (if any) and termination message.
The actual list is displayed in a new local file. If the search is done on a host
file, the result lines show the host absolute line numbers.
If the main file is local, the result lines show the relative line numbers.
The script creates a new file
for each execution. It is up to the user to dispose of these files.
Here is a sample ouput after searching for a string:
Searching CV- Green: K.DATA.DEVACCT for STRING 'next'
Include files ARE searched!
Actual line numbers are displayed
Started at 11/30/2000 11:39:56 AM
CV- Green:K.DATA.DEVACCT: 1 line(s) found **
2 : fix next line: $control nolist/$control list,map >>
CV- Green:DATABASE.INCLUDE.DEVACCT: 1 line(s) found **
36 : << The next equates define the sub-portions of an MPE filname.
Completed at 11/30/2000 11:39:56 AM