Mercurial > hg > octave-lyh
comparison src/pr-output.cc @ 3685:9d8306640373
[project @ 2000-06-28 19:25:02 by jwe]
author | jwe |
---|---|
date | Wed, 28 Jun 2000 19:25:04 +0000 |
parents | 505f5c35a2c9 |
children | 9507d6de9bbd |
comparison
equal
deleted
inserted
replaced
3684:f5f010fdbba5 | 3685:9d8306640373 |
---|---|
45 | 45 |
46 #include "defun.h" | 46 #include "defun.h" |
47 #include "error.h" | 47 #include "error.h" |
48 #include "gripes.h" | 48 #include "gripes.h" |
49 #include "oct-obj.h" | 49 #include "oct-obj.h" |
50 #include "oct-stream.h" | |
50 #include "pager.h" | 51 #include "pager.h" |
51 #include "pr-output.h" | 52 #include "pr-output.h" |
52 #include "sysdep.h" | 53 #include "sysdep.h" |
53 #include "utils.h" | 54 #include "utils.h" |
54 #include "variables.h" | 55 #include "variables.h" |
1749 { | 1750 { |
1750 os << "sorry, printing char matrices not implemented yet\n"; | 1751 os << "sorry, printing char matrices not implemented yet\n"; |
1751 } | 1752 } |
1752 } | 1753 } |
1753 | 1754 |
1755 DEFUN (disp, args, nargout, | |
1756 "-*- texinfo -*-\n\ | |
1757 @deftypefn {Built-in Function} {} disp (@var{x})\n\ | |
1758 Display the value of @var{x}. For example,\n\ | |
1759 \n\ | |
1760 @example\n\ | |
1761 disp (\"The value of pi is:\"), disp (pi)\n\ | |
1762 \n\ | |
1763 @print{} the value of pi is:\n\ | |
1764 @print{} 3.1416\n\ | |
1765 @end example\n\ | |
1766 \n\ | |
1767 @noindent\n\ | |
1768 Note that the output from @code{disp} always ends with a newline.\n\ | |
1769 \n\ | |
1770 If an output value is requested, @code{disp} prints nothing and\n\ | |
1771 returns the formatted output in a string.\n\ | |
1772 @end deftypefn\n\ | |
1773 @seealso{fdisp}") | |
1774 { | |
1775 octave_value retval; | |
1776 | |
1777 int nargin = args.length (); | |
1778 | |
1779 if (nargin == 1 && nargout < 2) | |
1780 { | |
1781 if (nargout == 0) | |
1782 args(0).print (octave_stdout); | |
1783 else | |
1784 { | |
1785 std::ostrstream buf; | |
1786 args(0).print (buf); | |
1787 buf << ends; | |
1788 char *tmp = buf.str (); | |
1789 retval = tmp; | |
1790 delete [] tmp; | |
1791 } | |
1792 } | |
1793 else | |
1794 print_usage ("disp"); | |
1795 | |
1796 return retval; | |
1797 } | |
1798 | |
1799 DEFUN (fdisp, args, , | |
1800 "-*- texinfo -*-\n\ | |
1801 @deftypefn {Built-in Function} {} fdisp (@var{fid}, @var{x})\n\ | |
1802 Display the value of @var{x} on the stream @var{fid}. For example,\n\ | |
1803 \n\ | |
1804 @example\n\ | |
1805 disp (stdout, \"The value of pi is:\"), disp (stdout, pi)\n\ | |
1806 \n\ | |
1807 @print{} the value of pi is:\n\ | |
1808 @print{} 3.1416\n\ | |
1809 @end example\n\ | |
1810 \n\ | |
1811 @noindent\n\ | |
1812 Note that the output from @code{disp} always ends with a newline.\n\ | |
1813 \n\ | |
1814 If an output value is requested, @code{disp} prints nothing and\n\ | |
1815 returns the formatted output in a string.\n\ | |
1816 @end deftypefn\n\ | |
1817 @seealso{disp}") | |
1818 { | |
1819 octave_value retval; | |
1820 | |
1821 int nargin = args.length (); | |
1822 | |
1823 if (nargin == 2) | |
1824 { | |
1825 int fid = octave_stream_list::get_file_number (args (0)); | |
1826 | |
1827 octave_stream os = octave_stream_list::lookup (fid, "fdisp"); | |
1828 | |
1829 if (! error_state) | |
1830 { | |
1831 ostream *osp = os.output_stream (); | |
1832 | |
1833 if (osp) | |
1834 args(1).print (*osp); | |
1835 else | |
1836 error ("fdisp: stream not open for writing"); | |
1837 } | |
1838 } | |
1839 else | |
1840 print_usage ("fdisp"); | |
1841 | |
1842 return retval; | |
1843 } | |
1844 | |
1754 static void | 1845 static void |
1755 init_format_state (void) | 1846 init_format_state (void) |
1756 { | 1847 { |
1757 free_format = false; | 1848 free_format = false; |
1758 plus_format = false; | 1849 plus_format = false; |