| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |
Robelle Sponsor Message

November 2002

Get the most out of your Robelle Tools

List and Edit Lines in a Fileset With Qedit

By François Desrochers

Qedit has the ability to list and search through multiple files, provided the referenced files are identified by Include, Use or Copy statements.

The Include keyword is commonly used in a lot of programming languages. A special character usually prefixes it. Qedit currently recognizes the following prefixes: dollar sign ($), pound sign (#), dot (.) or exclamation point (!).

The Use keyword is used in Qedit or Suprtool Use files and in Cognos Powerhouse e.g. Quiz, Quick. It does not have any prefix and is recognized as long as it is the first word on a line.

Copy statements are recognized in Cobol source files. This is part of the Cobol standards. To search for one of these keywords, you enter the corresponding option on the List command: $include, $use and $copy. For example:

/open rep23.src
/list $include “abort(914)”

This works well if the files you are working with already contain one of these keywords. It does not work so well if the files you want to list are of mixed types and do not use any of the keywords above. However, there is a way that you can search through an arbitrary fileset: turn that list of files into a list of $include lines and then search on that list using the $include option.

Here is a short command file that allows you to search a fileset.

Listset.Cmd:
parm filesetParm=”@”,searchString=””
purge fileset,temp
listfile !filesetParm > fileset,6
/t fileset
/d 1/3
/d “~” (p)
/c 1 “$include “ @
if “!searchString” = “” then
/lj $inc @
else
/lj $inc “!searchString”
endif

Parameters

The command file accepts two parameters. The first parameter, filesetParm, is the fileset you want to search. Its value is passed in to the Listfile command. As such, it can be any MPE fileset, simple or using wildcards. Since the command file uses the Listfile command, the command can work on Posix files if needed. The default is to look for all MPE files in the current group.

The second parameter, searchString, is the string you want to search on. This parameter is optional. The default is to list all the lines in each file.

Examples

To list the contents of all the MPE files in the current group: listset. To list the contents of all the MPE files whose names start with T: listset t@

To list only the lines containing the string “display” in all MPE files with names starting with test: listset test@,display. To search all MPE and Posix files for the string “display”: listset ../@,display

Editing Lines in a Fileset

Qedit does not have a built-in command to perform a series of changes on multiple files with a single step. Here is a simple command file that allows this.

Chgset.Cmd:
parm filesetParm=”@”
purge fileset,temp
listfile !filesetParm > fileset,6
purge chgcmds,temp
:beginfile chgcmds
:parm filename
:comment
:/t !filename,yes
:comment Insert all your edit commands in here
:comment be sure to start each line with a colon
:endfile
/t fileset
/d 1/3
/d “~” (p)
/c 1 “chgcmds “ @
/u *

The command file creates a temporary command file that will perform the actual edit operations. The version above does not contain any so you have to customize it with the things you want to do. All you have to do is insert the commands between the last :comment line and the :endfile. We recommend that you do not insert a Keep command immediately. Run it a few times without Keep to make sure it makes the appropriate changes. Once you have confirmed that everything works as expected, insert a Keep ,IfDirty to save the changes, if any.

Parameters

The command file accepts one parameter: filesetParm. This is the fileset you want to work on. Its value is passed in to the Listfile command. As such, it can be any MPE fileset, simple or using wildcards. Since the command file uses the Listfile command, the command can work on Posix files if needed. The default is to look for all MPE files in the current group.

Examples

To remove all blank lines from all the MPE files in the current group, the command file needs to be modified like this:

:beginfile chgcmds
:parm filename
:comment
:/t !filename,yes
:comment Insert all your edit commands in here
:comment be sure to start each line with a colon
:/d “~” (pattern)
:/k ,ifdirty
:endfile

To run it, enter chgset. To change all occurrences of the word Display to the word Print in files whose names start with T, the command file needs to be modified like this:

:beginfile chgcmds
:parm filename
:comment
:/t !filename,yes
:comment Insert all your edit commands in here
:comment be sure to start each line with a colon
:/c “Display” (s) “Print” @
:/k ,ifdirty
:endfile

To run it, enter chgset t@. To perform the same changes in all MPE and Posix files, enter chgset ./@

 


Copyright The 3000 NewsWire. All rights reserved.