Command File to Repeat Qedit Commands

By Ray Shahan, Ray _shahan@hotmail.com

Here is a quick command file that will allow you to execute QEDIT commands in a loop.

Save the commands as a file, perhaps named LOOPER. Then just type LOOPER in Qedit to execute it. The command file will prompt you for the search value to control the loop, and then the QEDIT command(s) you want to execute. Then it performs those commands on your entire file, but only on lines that match the string. To get instructions, just type LOOPER ? or LOOPER HELP.

What makes this a Qedit command file, rather than an MPE command file are the four lines that start with a slash ("/"). These are Qedit commands embedded within the MPE commands which can also take MPE variables as parameters. This command file should work on any version of Qedit released in the last 10 years.

PARM HELP_VAR=" "
IF UPS("!HELP_VAR") = "HELP" OR "!HELP_VAR" = "?"
  ECHO
  ECHO This cmd file will loop thru a source file executing QEDIT commands.
  ECHO It will prompt for 2 values it needs to perform the loop:
  ECHO
  ECHO       1). The search value that will control the loop via the
  ECHO           "find" command.
  ECHO       2). The QEDIT command and parms for that command that you
  ECHO           want the loop to execute. (Note: you can string many
  ECHO           QEDIT commands together as long as all the commands are
  ECHO           entered in 1 input statement, and of course, seperated
  ECHO           by semicolons (make sure the order of the commands makes
  ECHO           sence).
  ECHO
  ECHO To use this CMD file for executing a QEDIT command in a loop,
  ECHO you should keep the source code you want to act on in a "NEW"
  ECHO QEDIT workfile (Hint: use the ZZ command to mark and keep the
  ECHO                       part of the source you want the loop to
  ECHO                       be executed on from your current work file).
  ECHO After you have created the extract of the source file you want to
  ECHO loop thru, text the extract into a new QEDIT workfile and execute
  ECHO this cmd file.
  ECHO
  ECHO Written by Ray N. Shahan  12/05/2000
  ECHO
  RETURN
ENDIF

SETVAR VAR_TO_FIND " "
SETVAR OPERATION_TO_DO " "

INPUT VAR_TO_FIND;PROMPT="Enter a search value to control the loop: "; &
  WAIT=30
IF '!VAR_TO_FIND' = ' '
  ECHO Need a value to search for to process the loop
  RETURN
ENDIF

INPUT OPERATION_TO_DO;PROMPT="Enter QEDIT command to execute in loop: "; &
  WAIT=60
IF '!OPERATION_TO_DO' = ' '
  ECHO Need a QEDIT command to execute in the loop
  RETURN
ENDIF

SETVAR CIERROR 0
/[
/FIND \!VAR_TO_FIND\
WHILE CIERROR = 0
 /!OPERATION_TO_DO
 /F \!VAR_TO_FIND\
ENDWHILE

DELETEVAR VAR_TO_FIND
DELETEVAR OPERATION_TO_DO

Ray _shahan@hotmail.com
Currently at Alliant Foods, Minneapolis, MN.
December 6, 2000