W Write

W [n] [, file [, C|E|O|BLK] ] [, file-par|?] [ /[:col:] [ len] [, NS] ] [, SC]

Starting from the first record displayed, n records are copied to the specified Write file. The window is then positioned further by n records.

n Number of records to be transfered to the Write file.

The character '$' instead of a number n indicates the highest possible number 99999

Standard: n = 1.

file Name of the file to which the records should be written. (Write file).

If omitted: the file last used will be taken as the Write file.

C The output file will be closed after writing the last record.

E The output file will be opened in Open=Extend mode.

O An existing file will be overwritten (Open=Output).

Standard: see notes below.

BLK This option is only meaningful if the current Display file is a PAM file, and if the Pamkey mode is set (PK command). The BLK option will cause the blocks of data belonging to the Pam keys to be copied to the Write file.

Standard: In Pamkey mode, only the Pam keys are written to a SAM file.

file-par File attributes of the Write file, following the File or ADD-FILE-LINK command syntax. For example FCBTYPE=SAM SPACE=(120,30) VOLUME=PVT001 DEVICE=D3480

Standard: The file attributes of the Display file, with the exception of LOGLEN, VALLEN, VALPROP, DSPACE will be used for the output file.

If file-par is specified, then only these attributes are used for the output file. No attributes are taken from the Display file.

Example (parameter using FILE command syntax):

FCBTYPE=SAM,RECFORM=F,RECSIZE=80,BLKSIZE=(STD,16),SPACE=(120,30),VOLUME=PVT001,DEVICE=D3480

Example (parameter using ADD-FILE-LINK command syntax):

ACCESS=*SAM,REC-F=*FIX,REC-S=80,BUFFER-L=*STD(16)

? The SDF dialog facility of the /ADD-FILE-LINK (ADFL) command will be displayed.

The predefined values for the first two parameters (LINK-NAME=WFCB and FILE-NAME=...) may not be modified or deleted.

:col: Only that part of the Display record from column :col: will be copied (the record begins at :1:).

Standard: The record is copied in full.

len Only len number of bytes are tranfered from the specified column/beginning of record.

Standard: The full length of the record is copied, i.e. up to the end of the record.

NS No Skip. If the column :col: lies outside of the range to be written, then setting this option will force the relevant records to be written to the Write file. A 4 byte record will be written to the file which will consist of a record length field, but no data.

Standard: Records for which the :col: column range lies outside of the range to be written will not be output to the Write file.

SC If a Ruler is displayed on the screen, then the contents of this Ruler will be written as the first record of the Write file.

Standard: The Ruler is not written to the output file.

Notes:

Leaving the Display mode by pressing the K1 key, or by executing the LST command will automatically close the Write file. If another W command is entered without specifying a file name ( W [n] ), then the file last used will be opened in EXTEND mode (for a SAM file), or in INOUT mode (for a PAM/ISAM file).

If neither the E nor O option (Extend/Overwrite) is specified after the Write file name, then the following rules are valid:

If the Write file is being accessed for the first time in this current CFS run, then it will always be opened in Overwrite mode, i.e. the file will be created, or overwritten.

If the same Write file is accessed by a succession of W / S...=W commands, then it will be opened as standard in Open=Extend mode.

The E/O option gives the user the chance of setting a different Open mode of operation to the standard.

ISAM file records with duplicate keys can be written away to the Write file if DUPKEY mode has been set (DUPK command). If DUPKEY mode is not set (standard), then only the last such duplicate key record will be saved in the Write file.

The DUPKEY mode that was in force at the time the Write file was opened (the first W command) will remain valid. Subsequently changing the DUPKEY mode will have no effect on the Write file until the Display mode is terminated with the K1 key, and then re-activated.

A sequential file can be sorted in ascending order of a particular key by using the Write command:

W9999,file2,FCBTYPE=ISAM,KEYPOS=kk,KEYLEN=ll

kk and ll define the key on which the records of the sequential file should be sorted. If multiple records exist with the same key data, then the DUPK command (see above) must be entered before the Write command. The ISAM file thus sorted according to the desired criteria can then be converted back to a SAM file. Converting a SAM file to an ISAM file with simultaneous sorting according to a particular key can also be achieved by the Variable Action ONXCONV.

The Write command is also intended to provide a means of merging multiple files/library elements to an output file.

Another simple method is to use the Variable Action ONXLIST, with the NH (No Header) option. For further information, see page 5-.

Example:

The following CFS procedure searches the current Display file for a record containg a freely definable string (&ITEM), and writes it, as well as n records before and m records after to the output file, &W-FILE.

*PROC N,(&ITEM,&W-FILE,&M,&N)
SR
*&NUM=&M+&N
*&NUM=&NUM+1
S,&ITEM
*IF &CFSMSG(1,20) -= '>> SYNTACTICAL ERROR' SKIP .LOOP
*WRITESYS '&CFSMSG'
*SKIP .END2
.LOOP
*IF &CFSMSG(53,3) = 'NOT' SKIP .END
-&M
W&NUM,&W-FILE
S
*SKIP .LOOP
.END
*K1
.END2

Write a Display Record to a CFS Procedure Variable

W, (&var) [ /[:col:] [ len] ]

The first record displayed is copied partially or in full to the specified CFS procedure variable .

:col: Only that part of the Display record from column :col: will be copied (the record begins at :1:).

Standard: The complete record is copied.

len Only len number of bytes are tranfered from the specified column/beginning of record.

Standard: The full length will be written i.e. up to the end of the record. The maximum record length is restricted to 80 bytes.