[Access to Wang masthead]

The MOVEIT Procedure

MOVE files, don't COPY them!

From "VS Procedure",  Access 86, August 1986
  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  

Many users have occasional need to remove extra files from production libraries and put them in other libraries or on other disks or tapes. Often, these files have no further purpose other than historical reference. Since few systems have adequate disk storage space - let alone a surplus - it is often necessary to MOVE files from one library or volume to another; e.g., ARCHIVE the file.

There are many options available to accomplish this task. The most obvious are the Wang COPY and BACKUP utilities; less well known are USERAIDS SELCOPY and COPYMANY. Each has it's own advantages and disadvantages:

1. COPY: fast; allows release of extra space in the output file. Modifies the CREATION DATE, EXPIRATION DATE, and USER'S ID, making it difficult to understand the origins of the file.

2. BACKUP does not modify the file's history data, allows entry of multiple files, allows ambiguous ('wild card') references, and optionally produces a backup log. Unfortunately, is it relatively slow, cannot release unused file space or reorganize files, and is difficult for most users to use.

3. SELCOPY allows selection of files by attribute (CREATION DATE, ID, etc.), but uses the COPY utility and thus minces the file history. It too is confusing to use.

4. COPYMANY shows an entire library and allows the user to select the files to be copied. It will optionally release excess file space or reorganize the file. Based on COPY, it will modify the file's history data. Many users find it difficult to use.

5. The RENAME function of Procedure language (or the equivalent subroutine in USERSUBS) can be used to change the name of the library associated with a file. If the file is to be moved within a single volume and no other changes are necessary, this is the most efficient way to "move" the file.

MOVING files rather COPYING them

None of these utilities exactly fulfill the need for ARCHIVAL storage: that is, the file is MOVED to another location, removing the original copy in the process. The usual process for archiving files is as follows:

1. Identify the files to be moved.

2. Run COPY or BACKUP to make a second copy of the file.

3. Check to see that the output file has been properly created and contains all records.

4. SCRATCH the original file to free the disk space for other uses.

It's the last two items in the list above that are most subject to error. Not only is it difficult to tell if a file has been copied successfully, but it can also be a problem remembering to scratch the input file and being careful to scratch the right one. MOVEIT examines the condition of the output file before removing the original version, and lessens the chance that an important file gets scratched by accident.

How MOVEIT works

MOVEIT (see Figure 1) is a very simple procedure. It merely accepts the user's source and destination file parameters, then runs COPY to make a copy of the input file. If this copy is successful, the input file is scratched. In keeping with the primary purpose of this procedure - archival storage of static files - the index and data packing densities are set to 100% and the extra space is released from the output file.

This procedure uses some of the more powerful aspects of the Procedure language. For example, the existence of the input file is checked prior to prompting for the output parameters, and an appropriate error message displayed. The ALARM feature of the PROMPT verb is used dynamically; while normally set to "NO", it is revised to "YES" in the event of an error condition.

Note also the use of the CANCEL and ERROR EXIT options within the RUN statement (step S04). These statements detail the path to be followed in the event of error or cancel conditions during execution. They make it possible for the user to exit gracefully in abnormal circumstances, rather than have to face the usual cryptic DEBUG error messages.


The principle benefit of a procedure such as MOVEIT lies in its adaptation to your own conditions. From this simple concept, it is easy to see many ways to make it fit your shop's needs. Here are some ideas:

1. Set default values for the INPUT or OUTPUT parameters to meet a particular application, rather than extracting them initially from the user's defaults.

2. Try BACKUP instead of COPY so that a log will be produced. Combine all logs together using CREATE. Use UPDATFDR to release excess space on the output file.

3. Use READFDR to extract the CREATION DATE, MODIFICATION DATE, and USER ID; reset the output file to these values after the copy using UPDATFDR.

4. Substitute TAPECOPY to back information off to tape.

5. Use COPYMANY to allow selection of the files to be copied, then release excess space in the output files with UPDATFDR.

6. Use the RENAME function within Procedure to rename the FILE or LIBRARY name in place on the same volume. (Note that the LIBRARY can be renamed as well as the FILE when using the Procedure verb. This is similar in effect to COPYing the file to another library on the same volume.)

7. Use CREATE to combine small files into one larger file, rather than copying the small files to another library.

8. Run the VERIFY utility after the copy to ensure that the file is intact.

9. Use the FIND subroutine to locate files that match ambiguous selection criteria (ala the FILEDISP utility).

10. Add an argument list to be passed from a controlling procedure or program so that the MOVE can be used in non-interactive applications. (The GETPARM USERAID can also be used to generate GETPARM screens for the file parameters.)

That's all for this month. If you come up with a particularly clever variation on this procedure, please send a copy to me; I will try to feature some of these ideas in future columns.

Figure 1: The MOVEIT Procedure


* Accepts user-entered file parameters, then uses COPY to move
* the file to another location.

                         STRING (08)
                         STRING (06)


S00: EXTRACT             &INLIB    = INLIB,  &INVOL    = INVOL,
                         &OUTLIB   = OUTLIB, &OUTVOL   = OUTVOL

     CENTER BRIGHT LINE   "MOVEIT file utility";;
"Enter the desired FILE / LIBRARY / VOLUME to be moved";;
     CENTER              "INPUT FILE    =", UPPER &INFIL;
     CENTER              "      LIBRARY =", UPPER &INLIB;
     CENTER              "     VOLUME  =",  UPPER &INVOL, " ";;
     CENTER              "Press PF16 to EXIT";;

     IF &KEY = 16        GOTO S99
     IF &KEY NE 0        GOTO S01


     ASSIGN &MESSAGE     = "File " !! &INFIL !!
                         " not found - please re-enter"
     ASSIGN &ALARM       = "YES"
     GOTO S01

     ASSIGN &MESSAGE     = " "
     ASSIGN &ALARM       = "NO "

     CENTER BRIGHT LINE   "MOVEIT file utility";;
"Enter the destination FILE / LIBRARY / VOLUME";;
     CENTER              "OUTPUT FILE    =", UPPER &OUTFIL;
     CENTER              "       LIBRARY =", UPPER &OUTLIB;
     CENTER              "      VOLUME  =",  UPPER &OUTVOL, " ";;
     CENTER              "Press PF16 to EXIT";;

     IF &KEY = 16        GOTO S99
     IF &KEY NE 0        GOTO S03

S04: RUN COPY            CANCEL EXIT IS S06
                         ERROR  EXIT IS S05
     ENTER INPUT         FILE      = &INFIL,
                         LIBRARY   = &INLIB,
                         VOLUME    = &INVOL
     ENTER OPTIONS       IPACK     = "100",
                         DPACK     = "100"
     ENTER OUTPUT        FILE      = &OUTFIL,
                         LIBRARY   = &OUTLIB,
                         VOLUME    = &OUTVOL,
                         RELEASE   = "YES"
     ENTER EOJ           16

     IF S04 = 0          GOTO S07

S05: ASSIGN &RC          = S04
     CENTER BLINK LINE   "E R R O R ! !";;
     CENTER              "The COPY utility has return error code ",
     CENTER              "Press (RETURN) to exit program";;
     GOTO S99

     CENTER BLINK LINE   "COPY was cancelled by the operator";
     CENTER              "Press (RETURN) to return to the menu";
     GOTO S01


     ASSIGN &MESSAGE     = "File " !! &INFIL !!
                         " successfully copied"
     ASSIGN &INFIL       = " "
     GOTO S01


  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  

Copyright © 1986 Dennis S. Barnes
Reprints of this article are permitted without notification if the source of the information is clearly identified