HPlogo FCOPY Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 FCOPY Applications and Examples

Copying Files

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

You can use FCOPY to create new files, append one or more files onto an existing file, or extract portions from files.

New Disk Files

To create a new disk file as you copy information to it, use the NEW function. For example,

   >FROM=OLDDATA;TO=NEWDATA;NEW

In this example, the new file called NEWDATA has the default file characteristics described in appendix B and exists in the current account and group.

Appending Files

Often you need to string several files together. Use FCOPY to append a file to another as follows:

  1. Use the MPE FILE command to give the tofile append access (ACC=APPEND), and set its limit large enough to hold the contents of all the files you are appending to it.

    For example,

       >:FILE INFO3;REC=-80,10,F,ASCII;ACC=APPEND;DISC=500,2
    

    Refer to the MPE File System Reference Manual (30000-90236) for MPE V/E or the Accessing Files Programmers Guide (32650-90017) for MPE XL for instructions on calculating the amount of file space you would require.

  2. Copy the first file you want to append to the tofile. Type an asterisk in front of the tofile name to use the file characteristics described in the preceding FILE command instead of the default file characteristics. If the tofile is new, use the NEW function. For example,

       >FROM=INFO1;TO=*INFO3;NEW
    

    The system responds with the following message:

       EOF FOUND IN FROMFILE AFTER RECORD 19
    
    
    
       20 RECORDS PROCESSED * * * 0 ERRORS
    
  3. Copy any subsequent files in the order you want to append them. Use an asterisk alone to reuse the tofile in the previous command. For example,

    
    
       >FROM=INFO2;TO=*
    
    
    
       EOF FOUND IN FROMFILE AFTER RECORD 24
    
    
    
       25 RECORDS PROCESSED * * * 0 ERRORS
    

Extracting Parts of Files

Use the SUBSET function to extract portions of a file. You can define a subset as a set of continuous records or as a set of records with a certain pattern of characters or numbers. For example, a file may contain information about the employees in your company. Each record in the file describes one employee, and the employee's last name begins in column 1 of each record. To create a file containing all employees whose last name begins with "S," copy the subset of the employee file that contains the character "S" in column 1. To create a file containing all employees whose last name is "Smith," copy the subset of the employee file that contains the characters "Smith" beginning in column 1.

Defining Subsets

To copy a subset containing a particular character string from a file, use the following form of the SUBSET function:

   ;SUBSET [="characterstring"[,[column]][,EXCLUDE]]


Substitute the series of characters that you want to match for characterstring, and the beginning column number of the character string for column. For example, the command below copies the subset of all records with the characters "COLLEGE" beginning in column 40 from the EMPRECS file to the GRADS file:

   >FROM=EMPRECS;TO=GRADS;SUBSET="COLLEGE",40



   EOF FOUND IN FROMFILE AFTER RECORD 5985



   2859 RECORDS PROCESSED * * * 0 ERRORS

To copy a subset excluding specific records, use the EXCLUDE parameter. For example, the command below copies all records in EMPRECS, except those with the characters "COLLEGE" beginning in column 40, to the file NONGRADS.

   >FROM=EMPRECS;TO=NONGRADS;SUBSET="COLLEGE",40,EXCLUDE



   EOF FOUND IN FROMFILE AFTER RECORD 5985



   3127 RECORDS PROCESSED * * * 0 ERRORS
Feedback to webmaster