@@ -1233,11 +1233,13 @@ load_save_system::load (const octave_value_list& args, int nargout)
1233
1233
{
1234
1234
format = MAT_BINARY;
1235
1235
}
1236
+ // FIXME: Unsupported and silently ignored. Can we just delete this?
1236
1237
else if (argv[i] == " -force" || argv[i] == " -f" )
1237
1238
{
1238
1239
// Silently ignore this
1239
1240
// warning ("load: -force ignored");
1240
1241
}
1242
+ // FIXME: Unsupported and ignored. Can we just delete this?
1241
1243
else if (argv[i] == " -import" || argv[i] == " -i" )
1242
1244
{
1243
1245
warning (" load: -import ignored" );
@@ -1586,51 +1588,26 @@ DEFMETHOD (load, interp, args, nargout,
1586
1588
@deftypefnx {} {} load file options
1587
1589
@deftypefnx {} {} load file options v1 v2 @dots{}
1588
1590
@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}.
1591
1592
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.
1597
1597
1598
- If load is invoked using the functional form
1598
+ The @code{ load} command may also be invoked using the functional form
1599
1599
1600
1600
@example
1601
1601
load ("-option1", @dots{}, "file", "v1", @dots{})
1602
1602
@end example
1603
1603
1604
1604
@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.
1626
1607
1627
1608
Valid options for @code{load} are listed in the following table.
1628
1609
1629
1610
@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.
1634
1611
1635
1612
@item -ascii
1636
1613
Force 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.
1645
1622
Force Octave to assume the file is in @sc{hdf5} format. (@sc{hdf5} is a free,
1646
1623
portable binary format developed by the National Center for Supercomputing
1647
1624
Applications 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},
1649
1626
and 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
1653
1630
available if Octave was built with a link to the @sc{hdf5} libraries.
1654
1631
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
-
1660
1632
@item -text
1661
1633
Force Octave to assume the file is in Octave's text format.
1662
1634
@@ -1689,7 +1661,45 @@ Force Octave to assume the file is in @sc{matlab}'s version 6 binary format.
1689
1661
Force Octave to assume the file is in @sc{matlab}'s version 4 binary format.
1690
1662
1691
1663
@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}
1693
1703
@end deftypefn */ )
1694
1704
{
1695
1705
load_save_system& load_save_sys = interp.get_load_save_system ();
@@ -1708,35 +1718,31 @@ DEFMETHOD (save, interp, args, nargout,
1708
1718
@deftypefnx {} {@var{str} =} save ("-", @qcode{"@var{v1}"}, @qcode{"@var{v2}"}, @dots{})
1709
1719
Save the named variables @var{v1}, @var{v2}, @dots{}, in the file @var{file}.
1710
1720
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.
1723
1728
1724
- If save is invoked using the functional form
1729
+ The @code{ save} command may also be invoked using the functional form
1725
1730
1726
1731
@example
1727
1732
save ("-option1", @dots{}, "file", "v1", @dots{})
1728
1733
@end example
1729
1734
1730
1735
@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},
1732
1737
@dots{}) must be specified as character strings.
1733
1738
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}.
1736
1742
1737
1743
@table @code
1738
1744
@item -append
1739
- Append to the destination instead of overwriting.
1745
+ Append to the file instead of overwriting.
1740
1746
1741
1747
@item -ascii
1742
1748
Save a matrix in a text file without a header or any other information. The
@@ -1756,23 +1762,27 @@ Separate numbers with tabs.
1756
1762
Save the data in Octave's binary data format.
1757
1763
1758
1764
@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.
1760
1766
Use this format @strong{only} if you know that all the values to be saved can
1761
1767
be represented in single precision.
1762
1768
1763
1769
@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
1767
1773
with a link to the @sc{hdf5} libraries.
1768
1774
1769
1775
@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
1771
1777
format @strong{only} if you know that all the values to be saved can be
1772
1778
represented in single precision.
1773
1779
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}}.
1776
1786
1777
1787
@item -v7.3
1778
1788
@itemx -V7.3
@@ -1828,10 +1838,13 @@ Wildcards may also be used in the field name specifications when using the
1828
1838
1829
1839
@end table
1830
1840
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.
1835
1848
1836
1849
Example:
1837
1850
@@ -1844,8 +1857,9 @@ save -binary data a b*
1844
1857
@noindent
1845
1858
saves the variable @samp{a} and all variables beginning with @samp{b} to the
1846
1859
file @file{data} in Octave's binary format.
1860
+
1847
1861
@seealso{load, save_default_options, save_header_format_string, save_precision,
1848
- dlmread, csvread, fread }
1862
+ csvwrite, dlmwrite, fwrite }
1849
1863
@end deftypefn */ )
1850
1864
{
1851
1865
load_save_system& load_save_sys = interp.get_load_save_system ();
0 commit comments