From: rankin@eql.caltech.edu Sent: Wednesday, June 30, 1999 11:37 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: COPY w/extract function? In article <1999Jun30.162729.1@sldb4.slac.stanford.edu>,\ fairfield@sldb4.slac.stanford.edu writes... > In article <377A7E27.7650F91C@cwu.edu>, Robert Giden writes: >> I'm new to the VMS world but already it seems a functional component is >> missing (or hopefully I don't know where to look). I'd like a COPYFILE >> utilitly where I can specify the number of records to copy (not all of >> them). If this is done in VMS, I'd like to know how. Thanks' > > Interesting, but I'd never missed that missing feature. :-} No, > it's not something built into VMS, but I could think up three ways > to accomplish it in short order. [...] I've missed that feature plenty of files; so many times that I implemented a utility to perform it. ftp://ftp.wku.edu/vms/fileserv/extract.zip EXTRACT can do lots of stuff, but copying records is its fundamental model of execution. This `readme' file which summarizes its features has been posted several times before, but it's been a while so I'll repeat it. ----- + Extract.Doc + Pat Rankin, May'89 revised, Sep'91 Description: EXTRACT is a utility for retreiving records out of files. One may extract--in order to copy or display--a set of records from the start [/HEAD], middle [/RECORD=(START and/or END and/or COUNT)], or end [/TAIL] of one or more files. In addition, various conversions may be performed on the extracted records--such as tab expansion, column range selection, and simple edits like case conversion, blank compression, and parity-bit stripping. Usage: EXTRACT can be defined as a native DCL command, either system-wide or for the current process, or it can be used as a 'foreign' command by using a symbol for it or by invoking it via MCR. $ EXTRACT 'options' file[,file...] 'other_options' The file-specification(s) may contain wildcards. Options: Record selection options: /HEAD='k' !extract the first 'k' records /TAIL='k' ! " " last 'k' " /RECORD=(START='n',END='m',COUNT='k') !analogous to DUMP A negative value can be used to refer to positions relative to the end of the file for HEAD, TAIL, START, and END. The last record of the file is considered to be #-1, the one before that #-2, and so on. /HEAD='-k' !extract all but the last 'k' records /TAIL='-k' ! " " " " first 'k' " /BLOCK=(START='n',END='m',COUNT='k') !analogous to DUMP Block-mode is only partially implemented and not thoroughly tested. The record selection options (and the block option) are mutually exclusive. When no record option is specified, the default behavior depends upon the use of record modification options (see below): the whole file is extracted if any of the modification options are specified, otherwise just the first record is extracted (ie, /record=count=1 is the default). If the block option is used, none of the record modification options are allowed. Record modification options: /COLUMNS=([-,]p:q,...) !select specific columns /[NO]EXPAND_TABS ![don't] convert tabs into spaces /EDIT=(COLLAPSE,COMPRESS,LOWERCASE,TRIM,UNCOMMENT,UPCASE,- STRIP_TRAILING,IGNORE_QUOTES,FALLBACK,FORMAT) /TRANSLATE={ ASCII_TO_EBCDIC | EBCDIC_TO_ASCII } Selection by columns involves specifying one or more ranges of column positions; each range is a single number or a low and high pair separated by colon (":") or dash ("-"); if the first range is just a dash, then the rest of the list is interpreted as columns to reject instead of ones to select. Tab expansion is done by default if column selection or translation into EBCDIC is performed or if line numbering is being done, otherwise tabs are left as is unless the expand option is requested. The edit options are basically the same as those provided by the DCL lexical function F$EDIT(), with a few extensions added. Miscellanous options: /[NO]IDENTIFY ![don't] identify input file(s) /INDEX=n !alternate key for indexed file(s) /[NO]NUMBERS !prefix output rcrd w/ input rcrd no /OUTPUT=file !default is SYS$OUTPUT (terminal) /VFC_HEADER={ IGNORE | DATA | KEEP } !special rms handling Identification consists of displaying the name of each input file prior to extraction; it is done by default if wildcards are present or if a list of input files is specified or if the input file is located via an RMS searchlist. Indexed files can be processed on an alternate key; the default is index 0 (primary key). Output records can be prefixed with the original record number of the corresponding input record; default is no numbering. All output--including input file identification line--is written to the specified output file (analogous to TYPE/OUTPUT rather than COPY or CONVERT). Files having variable-with-fixed-control-area record format can receive special handling to preserve their format or to bring the control area (which is normally hidden) into the record as ordinary data. Installation: To define EXTRACT as a 'foreign' command simply create a DCL symbol that points to the image $ EXTRACT :== $disk:[directory]EXTRACT where 'disk' and 'directory' depend on the location of EXTRACT.EXE and the dollar sign ("$") preceding 'disk' is required. To define it as a native command, define a logical name that points to the .EXE and .CLD files and then use SET COMMAND to install it. $ DEFINE EXTRACT disk:[directory]EXTRACT $ SET COMMAND EXTRACT An entry for the system's online help is included and can be installed using the LIBRARY/HELP command. Author: Pat Rankin c/o Pactech Data & Research, Inc. Environmental Quality Laboratory California Institute of Technology Pasadena, CA + [pr] +