Add scratch file handles.
[pspp-builds.git] / doc / files.texi
index e1922b27d7228e972c6a962527c76540d954aa03..816a61ed31932519b8421216d201a70480d17ecc 100644 (file)
@@ -12,26 +12,27 @@ portable files.
 * MATCH FILES::                 Merge system files.
 * SAVE::                        Write to a system file.
 * SYSFILE INFO::                Display system file dictionary.
-* XSAVE::                       Write to a system file, as a transform.
+* XEXPORT::                     Write to a portable file, as a transformation.
+* XSAVE::                       Write to a system file, as a transformation.
 @end menu
 
-@node APPLY DICTIONARY, EXPORT, System and Portable Files, System and Portable Files
+@node APPLY DICTIONARY
 @section APPLY DICTIONARY
 @vindex APPLY DICTIONARY
 
 @display
-APPLY DICTIONARY FROM='filename'.
+APPLY DICTIONARY FROM=@{'filename',file_handle@}.
 @end display
 
 @cmd{APPLY DICTIONARY} applies the variable labels, value labels,
-and missing values from variables in a system file to corresponding
+and missing values taken from a file to corresponding
 variables in the active file.  In some cases it also updates the
 weighting variable.
 
-Specify a system file with a file name string or as a file handle
-(@pxref{FILE HANDLE}).  The dictionary in the system file will be read,
-but it will not replace the active file dictionary.  The system file's
-data will not be read.
+Specify a system file, portable file, or scratch file with a file name
+string or as a file handle (@pxref{File Handles}).  The dictionary in the
+file will be read, but it will not replace the active file dictionary.
+The file's data will not be read.
 
 Only variables with names that exist in both the active file and the
 system file are considered.  Variables with the same name but different
@@ -61,55 +62,77 @@ the active file weighting variable.
 active
 file.  The system file is not modified.
 
-@node EXPORT, GET, APPLY DICTIONARY, System and Portable Files
+@node EXPORT
 @section EXPORT
 @vindex EXPORT
 
 @display
 EXPORT
         /OUTFILE='filename'
+        /UNSELECTED=@{RETAIN,DELETE@}
+        /DIGITS=n
         /DROP=var_list
         /KEEP=var_list
         /RENAME=(src_names=target_names)@dots{}
+        /TYPE=@{COMM,TAPE@}
+        /MAP
 @end display
 
 The @cmd{EXPORT} procedure writes the active file dictionary and data to a
-specified portable file.
+specified portable file or scratch file.
+
+By default, cases excluded with FILTER are written to the
+file.  These can be excluded by specifying DELETE on the UNSELECTED
+subcommand.  Specifying RETAIN makes the default explicit.
+
+Portable files express real numbers in base 30.  Integers are always
+expressed to the maximum precision needed to make them exact.
+Non-integers are, by default, expressed to the machine's maximum
+natural precision (approximately 15 decimal digits on many machines).
+If many numbers require this many digits, the portable file may
+significantly increase in size.  As an alternative, the DIGITS
+subcommand may be used to specify the number of decimal digits of
+precision to write.  DIGITS applies only to non-integers.
 
 The OUTFILE subcommand, which is the only required subcommand, specifies
-the portable file to be written as a file name string or a file handle
-(@pxref{FILE HANDLE}).
+the portable file or scratch file to be written as a file name string or
+a file handle (@pxref{File Handles}).
 
 DROP, KEEP, and RENAME follow the same format as the SAVE procedure
 (@pxref{SAVE}).
 
+The TYPE subcommand specifies the character set for use in the
+portable file.  Its value is currently not used.
+
+The MAP subcommand is currently ignored.
+
 @cmd{EXPORT} is a procedure.  It causes the active file to be read.
 
-@node GET, IMPORT, EXPORT, System and Portable Files
+@node GET
 @section GET
 @vindex GET
 
 @display
 GET
-        /FILE='filename'
+        /FILE=@{'filename',file_handle@}
         /DROP=var_list
         /KEEP=var_list
         /RENAME=(src_names=target_names)@dots{}
 @end display
 
 @cmd{GET} clears the current dictionary and active file and
-replaces them with the dictionary and data from a specified system file.
+replaces them with the dictionary and data from a specified file.
 
 The FILE subcommand is the only required subcommand.  Specify the system
-file to be read as a string file name or a file handle (@pxref{FILE
-HANDLE}).
+file, portable file, or scratch file to be read as a string file name or
+a file handle (@pxref{File Handles}).
 
-By default, all the variables in a system file are read.  The DROP
+By default, all the variables in a file are read.  The DROP
 subcommand can be used to specify a list of variables that are not to be
 read.  By contrast, the KEEP subcommand can be used to specify variable
 that are to be read, with all other variables not read.
 
-Normally variables in a system file retain the names that they were
+Normally variables in a file retain the names that they were
 saved under.  Use the RENAME subcommand to change these names.  Specify,
 within parentheses, a list of variable names followed by an equals sign
 (@samp{=}) and the names that they should be renamed to.  Multiple
@@ -122,15 +145,18 @@ eliminated.  When this is done, only a single variable may be renamed at
 once.  For instance, @samp{/RENAME=A=B}.  This alternate syntax is
 deprecated.
 
-DROP, KEEP, and RENAME are performed in left-to-right order.  They
-each may be present any number of times.  @cmd{GET} never modifies a
-system file on disk.  Only the active file read from the system file
+DROP, KEEP, and RENAME are executed in left-to-right order.  
+Each may be present any number of times.  @cmd{GET} never modifies a
+file on disk.  Only the active file read from the file
 is affected by these subcommands.
 
 @cmd{GET} does not cause the data to be read, only the dictionary.  The data
 is read later, when a procedure is executed.
 
-@node IMPORT, MATCH FILES, GET, System and Portable Files
+Use of @cmd{GET} to read a portable file or scratch file is a PSPP
+extension.
+
+@node IMPORT
 @section IMPORT
 @vindex IMPORT
 
@@ -145,11 +171,12 @@ IMPORT
 
 The @cmd{IMPORT} transformation clears the active file dictionary and
 data and
-replaces them with a dictionary and data from a portable file on disk.
+replaces them with a dictionary and data from a system, portable file,
+or scratch file.
 
 The FILE subcommand, which is the only required subcommand, specifies
 the portable file to be read as a file name string or a file handle
-(@pxref{FILE HANDLE}).
+(@pxref{File Handles}).
 
 The TYPE subcommand is currently not used.
 
@@ -158,43 +185,49 @@ DROP, KEEP, and RENAME follow the syntax used by @cmd{GET} (@pxref{GET}).
 @cmd{IMPORT} does not cause the data to be read, only the dictionary.  The
 data is read later, when a procedure is executed.
 
-@node MATCH FILES, SAVE, IMPORT, System and Portable Files
+Use of @cmd{IMPORT} to read a system file or scratch file is a PSPP
+extension.
+
+@node MATCH FILES
 @section MATCH FILES
 @vindex MATCH FILES
 
 @display
 MATCH FILES
-        /BY var_list
         /@{FILE,TABLE@}=@{*,'filename'@}
         /DROP=var_list
         /KEEP=var_list
         /RENAME=(src_names=target_names)@dots{}
         /IN=var_name
+
+        /BY var_list
         /FIRST=var_name
         /LAST=var_name
         /MAP
 @end display
 
-@cmd{MATCH FILES} merges one or more system files, optionally
+@cmd{MATCH FILES} merges one or more system, portable, or scratch files,
+optionally
 including the active file.  Records with the same values for BY
 variables are combined into a single record.  Records with different
-values are output in order.  Thus, multiple sorted system files are
-combined into a single sorted system file based on the value of the BY
+values are output in order.  Thus, multiple sorted files are
+combined into a single sorted file based on the value of the BY
 variables.  The results of the merge become the new active file.
 
 The BY subcommand specifies a list of variables that are used to match
-records from each of the system files.  Variables specified must exist
+records from each of the files.  Variables specified must exist
 in all the files specified on FILE and TABLE.  BY should usually be
-specified.  If TABLE is used then BY is required.
+specified.  If TABLE or IN is used then BY is required.
 
-Specify FILE with a system file as a file name string or file handle
-(@pxref{FILE HANDLE}), or with an asterisk (@samp{*}) to
+Specify FILE with a system, portable, or scratch file as a file name
+string or file handle
+(@pxref{File Handles}), or with an asterisk (@samp{*}) to
 indicate the current active file.  The files specified on FILE are
 merged together based on the BY variables, or combined case-by-case if
 BY is not specified.  Normally at least two FILE subcommands should be
 specified.
 
-Specify TABLE with a system file to use it as a @dfn{table
+Specify TABLE with a file to use it as a @dfn{table
 lookup file}.  Records in table lookup files are not used up after
 they've been used once.  This means that data in table lookup files can
 correspond to any number of records in FILE files.  Table lookup files
@@ -203,45 +236,67 @@ It is incorrect to have records with duplicate BY values in table lookup
 files.
 
 Any number of FILE and TABLE subcommands may be specified.  Each
-instance of FILE or TABLE can be followed by DROP, KEEP, and/or RENAME
-subcommands.  These take the same form as the corresponding subcommands
-of @cmd{GET} (@pxref{GET}), and perform the same functions.
+instance of FILE or TABLE can be followed by any sequence of DROP,
+KEEP, or RENAME subcommands.  These have the same form and meaning as
+the corresponding subcommands of @cmd{GET} (@pxref{GET}), but apply
+only to variables in the given file.
+
+Each FILE or TABLE may optionally be followed by an IN subcommand,
+which creates a numeric variable with the specified name and format
+F1.0.  The IN variable takes value 1 in a case if the given file
+contributed a row to the merged file, 0 otherwise.  The DROP, KEEP,
+and RENAME subcommands do not affect IN variables.
 
 Variables belonging to files that are not present for the current case
 are set to the system-missing value for numeric variables or spaces for
 string variables.
 
-IN, FIRST, LAST, and MAP are currently not used.
+FIRST, LAST, and MAP are currently ignored.
 
 @cmd{MATCH FILES} may not be specified following @cmd{TEMPORARY}
 (@pxref{TEMPORARY}) if the active file is used as an input source.
 
-@node SAVE, SYSFILE INFO, MATCH FILES, System and Portable Files
+Use of portable or scratch files on @cmd{MATCH FILES} is a PSPP
+extension.
+
+@node SAVE
 @section SAVE
 @vindex SAVE
 
 @display
 SAVE
-        /OUTFILE='filename'
+        /OUTFILE=@{'filename',file_handle@}
+        /UNSELECTED=@{RETAIN,DELETE@}
         /@{COMPRESSED,UNCOMPRESSED@}
+        /PERMISSIONS=@{WRITEABLE,READONLY@}
         /DROP=var_list
         /KEEP=var_list
         /VERSION=version
         /RENAME=(src_names=target_names)@dots{}
+        /NAMES
+        /MAP
 @end display
 
 The @cmd{SAVE} procedure causes the dictionary and data in the active
 file to
-be written to a system file.
+be written to a system file or scratch file.
+
+OUTFILE is the only required subcommand.  Specify the system file or
+scratch file to be written as a string file name or a file handle
+(@pxref{File Handles}).
 
-OUTFILE is the only required subcommand.  Specify the system
-file to be written as a string file name or a file handle (@pxref{FILE
-HANDLE}).
+By default, cases excluded with FILTER are written to the system file.
+These can be excluded by specifying DELETE on the UNSELECTED
+subcommand.  Specifying RETAIN makes the default explicit.
 
 The COMPRESS and UNCOMPRESS subcommand determine whether the saved
 system file is compressed.  By default, system files are compressed.
 This default can be changed with the SET command (@pxref{SET}).
 
+The PERMISSIONS subcommand specifies permissions for the new system
+file.  WRITEABLE, the default, creates the file with read and write
+permission.  READONLY creates the file for read-only access.
+
 By default, all the variables in the active file dictionary are written
 to the system file.  The DROP subcommand can be used to specify a list
 of variables not to be written.  In contrast, KEEP specifies variables
@@ -266,14 +321,15 @@ the active file.  DROP, KEEP, and RENAME only affect the system file
 written to disk.
 
 The VERSION subcommand specifies the version of the file format. Valid
-versions are '3' and '3x'.  Version 3x system files are identical to
-version 3 files, except that variable names greater than 8 bytes will
-be truncated.  The default version is 3.  The VERSION subcommand is
-optional.  There is no need ever to use it.
+versions are 2 and 3.  The default version is 3.  In version 2 system
+files, variable names longer than 8 bytes will be truncated.  The two
+versions are otherwise identical.
+
+The NAMES and MAP subcommands are currently ignored.
 
 @cmd{SAVE} causes the data to be read.  It is a procedure.
 
-@node SYSFILE INFO, XSAVE, SAVE, System and Portable Files
+@node SYSFILE INFO
 @section SYSFILE INFO
 @vindex SYSFILE INFO
 
@@ -289,7 +345,40 @@ a system file and displays information on its dictionary.
 
 @cmd{SYSFILE INFO} does not affect the current active file.
 
-@node XSAVE,  , SYSFILE INFO, System and Portable Files
+@node XEXPORT
+@section XEXPORT
+@vindex XEXPORT
+
+@display
+EXPORT
+        /OUTFILE='filename'
+        /DIGITS=n
+        /DROP=var_list
+        /KEEP=var_list
+        /RENAME=(src_names=target_names)@dots{}
+        /TYPE=@{COMM,TAPE@}
+        /MAP
+@end display
+
+The @cmd{EXPORT} transformation writes the active file dictionary and
+data to a specified portable file.
+
+This transformation is a PSPP extension.
+
+It is similar to the @cmd{EXPORT} procedure, with two differences:
+
+@itemize
+@item
+@cmd{XEXPORT} is a transformation, not a procedure.  It is executed when
+the data is read by a procedure or procedure-like command.
+
+@item
+@cmd{XEXPORT} does not support the UNSELECTED subcommand.
+@end itemize
+
+@xref{EXPORT}, for more information.
+
+@node XSAVE,  , XEXPORT, System and Portable Files
 @section XSAVE
 @vindex XSAVE
 
@@ -297,17 +386,27 @@ a system file and displays information on its dictionary.
 XSAVE
         /OUTFILE='filename'
         /@{COMPRESSED,UNCOMPRESSED@}
+        /PERMISSIONS=@{WRITEABLE,READONLY@}
         /DROP=var_list
         /KEEP=var_list
+        /VERSION=version
         /RENAME=(src_names=target_names)@dots{}
+        /NAMES
+        /MAP
 @end display
 
 The @cmd{XSAVE} transformation writes the active file dictionary and
-data to a
-system file stored on disk.
+data to a system file or scratch file.  It is similar to the @cmd{SAVE}
+procedure, with two differences:
+
+@itemize
+@item
+@cmd{XSAVE} is a transformation, not a procedure.  It is executed when
+the data is read by a procedure or procedure-like command.
+
+@item
+@cmd{XSAVE} does not support the UNSELECTED subcommand.
+@end itemize
 
-@cmd{XSAVE} is a transformation, not a procedure.  It is executed when the
-data is read by a procedure or procedure-like command.  In all other
-respects, @cmd{XSAVE} is identical to @cmd{SAVE}.  @xref{SAVE}, for
-more information on syntax and usage.
+@xref{SAVE}, for more information.
 @setfilename ignored