@@ -1233,11 +1233,13 @@ load_save_system::load (const octave_value_list& args, int nargout)
12331233 {
12341234 format = MAT_BINARY;
12351235 }
1236+ // FIXME: Unsupported and silently ignored. Can we just delete this?
12361237 else if (argv[i] == " -force" || argv[i] == " -f" )
12371238 {
12381239 // Silently ignore this
12391240 // warning ("load: -force ignored");
12401241 }
1242+ // FIXME: Unsupported and ignored. Can we just delete this?
12411243 else if (argv[i] == " -import" || argv[i] == " -i" )
12421244 {
12431245 warning (" load: -import ignored" );
@@ -1586,51 +1588,26 @@ DEFMETHOD (load, interp, args, nargout,
15861588@deftypefnx {} {} load file options
15871589@deftypefnx {} {} load file options v1 v2 @dots{}
15881590@deftypefnx {} {S =} load ("file", "options", "v1", "v2", @dots{})
1589- Load the named variables @var{v1}, @var{v2}, @dots{}, from the file
1590- @var{file}.
1591+ Load the named variables @var{v1}, @var{v2}, @dots{}, from the file @var{file}.
15911592
1592- If no variables are specified then all variables found in the
1593- file will be loaded. As with @code{save}, the list of variables to extract
1594- can be full names or use a pattern syntax. The format of the file is
1595- automatically detected but may be overridden by supplying the appropriate
1596- option.
1593+ If no variables are specified then all variables found in the file will be
1594+ loaded. Otherwise, full variable names or pattern syntax can be used to
1595+ specify the variables to save. The format of the file is automatically
1596+ detected but may be overridden by supplying the appropriate option.
15971597
1598- If load is invoked using the functional form
1598+ The @code{ load} command may also be invoked using the functional form
15991599
16001600@example
16011601load ("-option1", @dots{}, "file", "v1", @dots{})
16021602@end example
16031603
16041604@noindent
1605- then the @var{options}, @var{file}, and variable name arguments
1606- (@var{v1}, @dots{}) must be specified as character strings.
1607-
1608- If a variable that is not marked as global is loaded from a file when a
1609- global symbol with the same name already exists, it is loaded in the
1610- global symbol table. Also, if a variable is marked as global in a file
1611- and a local symbol exists, the local symbol is moved to the global
1612- symbol table and given the value from the file.
1613-
1614- If invoked with a single output argument, Octave returns data instead
1615- of inserting variables in the symbol table. If the data file contains
1616- only numbers (TAB- or space-delimited columns), a matrix of values is
1617- returned. Otherwise, @code{load} returns a structure with members
1618- corresponding to the names of the variables in the file.
1619-
1620- The @code{load} command can read data stored in Octave's text and
1621- binary formats, and @sc{matlab}'s binary format. If compiled with zlib
1622- support, it can also load gzip-compressed files. It will automatically
1623- detect the type of file and do conversion from different floating point
1624- formats (currently only IEEE big and little endian, though other formats
1625- may be added in the future).
1605+ where the @var{options}, @var{file}, and variable name arguments (@var{v1},
1606+ @dots{}) must be specified as character strings.
16261607
16271608Valid options for @code{load} are listed in the following table.
16281609
16291610@table @code
1630- @item -force
1631- This option is accepted for backward compatibility but is ignored.
1632- Octave now overwrites variables currently in memory with
1633- those of the same name found in the file.
16341611
16351612@item -ascii
16361613Force Octave to assume the file contains columns of numbers in text format
@@ -1645,18 +1622,13 @@ Force Octave to assume the file is in Octave's binary format.
16451622Force Octave to assume the file is in @sc{hdf5} format. (@sc{hdf5} is a free,
16461623portable binary format developed by the National Center for Supercomputing
16471624Applications at the University of Illinois.) Note that @code{load} is only
1648- designed to read @sc{hdf5} files that were created by itself with @code{save},
1625+ designed to read @sc{hdf5} files that were created by Octave with @code{save},
16491626and attempts to read other @sc{hdf5} files may fail or produce unpredictable
1650- results. The @code{-hdf5} option also provides a limited ability to read
1651- files created using @sc{matlab}'s @code{-v7.3} option (which saves in @sc{hdf5}
1652- format) although many data types are not yet supported. This format is only
1627+ results. The @code{-hdf5} option provides a limited ability to read files
1628+ created using @sc{matlab}'s @code{-v7.3} option (which saves in @sc{hdf5}
1629+ format) although many data types are not yet supported. This format is only
16531630available if Octave was built with a link to the @sc{hdf5} libraries.
16541631
1655- @item -import
1656- This option is accepted for backward compatibility but is ignored.
1657- Octave can now support multi-dimensional HDF data and automatically
1658- modifies variable names if they are invalid Octave identifiers.
1659-
16601632@item -text
16611633Force Octave to assume the file is in Octave's text format.
16621634
@@ -1689,7 +1661,45 @@ Force Octave to assume the file is in @sc{matlab}'s version 6 binary format.
16891661Force Octave to assume the file is in @sc{matlab}'s version 4 binary format.
16901662
16911663@end table
1692- @seealso{save, dlmwrite, csvwrite, fwrite}
1664+
1665+ The list of variables to load may use wildcard patterns (glob patterns)
1666+ containing the following special characters:
1667+
1668+ @table @code
1669+ @item ?
1670+ Match any single character.
1671+
1672+ @item *
1673+ Match zero or more characters.
1674+
1675+ @item [ @var{list} ]
1676+ Match the list of characters specified by @var{list}. If the first character
1677+ is @code{!} or @code{^}, match all characters except those specified by
1678+ @var{list}. For example, the pattern @code{[a-zA-Z]} will match all lower and
1679+ uppercase alphabetic characters.
1680+
1681+ @end table
1682+
1683+ If invoked with a single output argument, Octave assigns loaded data to the
1684+ output instead of inserting variables in the symbol table. If the data file
1685+ contains only numbers (TAB- or space-delimited columns), a matrix of values is
1686+ returned. Otherwise, @code{load} returns a structure with members
1687+ corresponding to the names of the variables in the file.
1688+
1689+ The @code{load} command can read data stored in Octave's text and binary
1690+ formats, @sc{matlab}'s binary format, and many simple formats such as
1691+ comma-separated-values (CSV). If compiled with zlib support, it can also load
1692+ gzip-compressed files. It will automatically detect the type of file and do
1693+ conversion from different floating point formats (currently only IEEE big and
1694+ little endian, though other formats may be added in the future).
1695+
1696+ Programming Note: If a variable that is not marked as global is loaded from a
1697+ file when a global symbol with the same name already exists, it is loaded in
1698+ the global symbol table. Also, if a variable is marked as global in a file and
1699+ a local symbol exists, the local symbol is moved to the global symbol table and
1700+ given the value from the file.
1701+
1702+ @seealso{save, csvread, dlmread, fread, textscan}
16931703@end deftypefn */ )
16941704{
16951705 load_save_system& load_save_sys = interp.get_load_save_system ();
@@ -1708,35 +1718,31 @@ DEFMETHOD (save, interp, args, nargout,
17081718@deftypefnx {} {@var{str} =} save ("-", @qcode{"@var{v1}"}, @qcode{"@var{v2}"}, @dots{})
17091719Save the named variables @var{v1}, @var{v2}, @dots{}, in the file @var{file}.
17101720
1711- The special filename @samp{-} may be used to return the content of the
1712- variables as a string. If no variable names are listed, Octave saves all the
1713- variables in the current scope. Otherwise, full variable names or pattern
1714- syntax can be used to specify the variables to save. If the @option{-struct}
1715- modifier is used then the fields of the @strong{scalar} struct are saved as if
1716- they were variables with the corresponding field names. The @option{-struct}
1717- option can be combined with specific field names @var{f1}, @var{f2}, @dots{} to
1718- write only certain fields to the file.
1719-
1720- Valid options for the @code{save} command are listed in the following table.
1721- Options that modify the output format override the format specified by
1722- @code{save_default_options}.
1721+ If no variable names are listed, Octave saves all the variables in the current
1722+ scope. Otherwise, full variable names or pattern syntax can be used to specify
1723+ the variables to save. If the @option{-struct} modifier is used then the
1724+ fields of the @strong{scalar} struct are saved as if they were variables with
1725+ the corresponding field names. The @option{-struct} option can be combined
1726+ with specific field names @var{f1}, @var{f2}, @dots{} to write only certain
1727+ fields to the file.
17231728
1724- If save is invoked using the functional form
1729+ The @code{ save} command may also be invoked using the functional form
17251730
17261731@example
17271732save ("-option1", @dots{}, "file", "v1", @dots{})
17281733@end example
17291734
17301735@noindent
1731- then the @var{options}, @var{file}, and variable name arguments (@var{v1},
1736+ where the @var{options}, @var{file}, and variable name arguments (@var{v1},
17321737@dots{}) must be specified as character strings.
17331738
1734- If called with a filename of @qcode{"-"}, write the output to stdout if nargout
1735- is 0, otherwise return the output in a character string.
1739+ Valid options for the @code{save} command are listed in the following table.
1740+ Options that modify the output format override the format specified by
1741+ @code{save_default_options}.
17361742
17371743@table @code
17381744@item -append
1739- Append to the destination instead of overwriting.
1745+ Append to the file instead of overwriting.
17401746
17411747@item -ascii
17421748Save a matrix in a text file without a header or any other information. The
@@ -1756,23 +1762,27 @@ Separate numbers with tabs.
17561762Save the data in Octave's binary data format.
17571763
17581764@item -float-binary
1759- Save the data in Octave's binary data format but using only single precision.
1765+ Save the data in Octave's binary data format using just single precision.
17601766Use this format @strong{only} if you know that all the values to be saved can
17611767be represented in single precision.
17621768
17631769@item -hdf5
1764- Save the data in @sc{hdf5} format. (HDF5 is a free, portable, binary format
1765- developed by the National Center for Supercomputing Applications at the
1766- University of Illinois.) This format is only available if Octave was built
1770+ Save the data in @sc{hdf5} format. (@sc{hdf5} is a free, portable, binary
1771+ format developed by the National Center for Supercomputing Applications at the
1772+ University of Illinois.) This format is only available if Octave was built
17671773with a link to the @sc{hdf5} libraries.
17681774
17691775@item -float-hdf5
1770- Save the data in @sc{hdf5} format but using only single precision. Use this
1776+ Save the data in @sc{hdf5} format using just single precision. Use this
17711777format @strong{only} if you know that all the values to be saved can be
17721778represented in single precision.
17731779
1774- @item -text
1775- Save the data in Octave's text data format. (default)
1780+ @item -text (default)
1781+ Save the data in Octave's text data format. The
1782+ @ref{XREFsave_precision,,@code{save_precision}} function specifies the number
1783+ of significant figures to use when saving data (default: 17). The header of
1784+ the text data file can be configure with
1785+ @ref{XREFsave_header_format_string,,@code{save_header_format_string}}.
17761786
17771787@item -v7.3
17781788@itemx -V7.3
@@ -1828,10 +1838,13 @@ Wildcards may also be used in the field name specifications when using the
18281838
18291839@end table
18301840
1831- Except when using the @sc{matlab} binary data file format or the @samp{-ascii}
1832- format, saving global variables also saves the global status of the variable.
1833- If the variable is restored at a later time using @samp{load}, it will be
1834- restored as a global variable.
1841+ Programming Notes: If called with the special filename @qcode{"-"} the data to
1842+ be saved is returned as a string rather than writing it to an actual file.
1843+
1844+ When saving global variables the global status of the variable is also stored.
1845+ If the variable is restored at a later time using @code{load}, it will be
1846+ restored as a global variable. Global status is @emph{not} preserved if
1847+ using a @sc{matlab} binary data file format or the @option{-ascii} format.
18351848
18361849Example:
18371850
@@ -1844,8 +1857,9 @@ save -binary data a b*
18441857@noindent
18451858saves the variable @samp{a} and all variables beginning with @samp{b} to the
18461859file @file{data} in Octave's binary format.
1860+
18471861@seealso{load, save_default_options, save_header_format_string, save_precision,
1848- dlmread, csvread, fread }
1862+ csvwrite, dlmwrite, fwrite }
18491863@end deftypefn */ )
18501864{
18511865 load_save_system& load_save_sys = interp.get_load_save_system ();
0 commit comments