comparison src/ov.cc @ 4005:fc000ebb19df

[project @ 2002-07-25 21:01:16 by jwe]
author jwe
date Thu, 25 Jul 2002 21:01:16 +0000
parents 95663a3a2682
children a8621d87fbf5
comparison
equal deleted inserted replaced
4004:ca854fb51a88 4005:fc000ebb19df
57 57
58 #include "defun.h" 58 #include "defun.h"
59 #include "error.h" 59 #include "error.h"
60 #include "gripes.h" 60 #include "gripes.h"
61 #include "pager.h" 61 #include "pager.h"
62 #include "parse.h"
62 #include "pr-output.h" 63 #include "pr-output.h"
63 #include "utils.h" 64 #include "utils.h"
64 #include "variables.h" 65 #include "variables.h"
65 66
66 // We are likely to have a lot of octave_value objects to allocate, so 67 // We are likely to have a lot of octave_value objects to allocate, so
67 // make the grow_size large. 68 // make the grow_size large.
68 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); 69 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024);
70
71 // If TRUE, turn off printing of results in functions (as if a
72 // semicolon has been appended to each statement).
73 static bool Vsilent_functions;
69 74
70 // If TRUE, allow assignments like 75 // If TRUE, allow assignments like
71 // 76 //
72 // octave> A(1) = 3; A(2) = 5 77 // octave> A(1) = 3; A(2) = 5
73 // 78 //
940 945
941 return retval; 946 return retval;
942 } 947 }
943 948
944 void 949 void
945 octave_value::print_with_name (std::ostream& output_buf, const std::string& name, 950 octave_value::print_with_name (std::ostream& output_buf,
951 const std::string& name,
946 bool print_padding) const 952 bool print_padding) const
947 { 953 {
948 bool pad_after = print_name_tag (output_buf, name); 954 if (! (evaluating_function_body && Vsilent_functions))
949 955 {
950 print (output_buf); 956 bool pad_after = print_name_tag (output_buf, name);
951 957
952 if (print_padding && pad_after) 958 print (output_buf);
953 newline (output_buf); 959
960 if (print_padding && pad_after)
961 newline (output_buf);
962 }
954 } 963 }
955 964
956 static void 965 static void
957 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) 966 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2)
958 { 967 {
1606 1615
1607 return 0; 1616 return 0;
1608 } 1617 }
1609 1618
1610 static int 1619 static int
1620 silent_functions (void)
1621 {
1622 Vsilent_functions = check_preference ("silent_functions");
1623
1624 return 0;
1625 }
1626
1627 static int
1611 struct_levels_to_print (void) 1628 struct_levels_to_print (void)
1612 { 1629 {
1613 double val; 1630 double val;
1614 if (builtin_real_scalar_variable ("struct_levels_to_print", val) 1631 if (builtin_real_scalar_variable ("struct_levels_to_print", val)
1615 && ! xisnan (val)) 1632 && ! xisnan (val))
1719 elements that have not been given a value are set to zero. If the value\n\ 1736 elements that have not been given a value are set to zero. If the value\n\
1720 of @code{resize_on_range_error} is 0, an error message is printed and\n\ 1737 of @code{resize_on_range_error} is 0, an error message is printed and\n\
1721 control is returned to the top level. The default value is 1.\n\ 1738 control is returned to the top level. The default value is 1.\n\
1722 @end defvr"); 1739 @end defvr");
1723 1740
1741 DEFVAR (silent_functions, 0.0, silent_functions,
1742 "-*- texinfo -*-\n\
1743 @defvr {Built-in Variable} silent_functions\n\
1744 If the value of @code{silent_functions} is nonzero, internal output\n\
1745 from a function is suppressed. Otherwise, the results of expressions\n\
1746 within a function body that are not terminated with a semicolon will\n\
1747 have their values printed. The default value is 0.\n\
1748 \n\
1749 For example, if the function\n\
1750 \n\
1751 @example\n\
1752 function f ()\n\
1753 2 + 2\n\
1754 endfunction\n\
1755 @end example\n\
1756 \n\
1757 @noindent\n\
1758 is executed, Octave will either print @samp{ans = 4} or nothing\n\
1759 depending on the value of @code{silent_functions}.\n\
1760 @end defvr");
1761
1724 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, 1762 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print,
1725 "-*- texinfo -*-\n\ 1763 "-*- texinfo -*-\n\
1726 @defvr {Built-in Variable} struct_levels_to_print\n\ 1764 @defvr {Built-in Variable} struct_levels_to_print\n\
1727 You can tell Octave how many structure levels to display by setting the\n\ 1765 You can tell Octave how many structure levels to display by setting the\n\
1728 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\ 1766 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\