gnumeric r16508 - in branches/gnumeric-1-8: . plugins/fn-logical



Author: mortenw
Date: Fri Apr 11 23:52:11 2008
New Revision: 16508
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16508&view=rev

Log:
2008-04-11  Morten Welinder  <terra gnome org>

	* functions.c (gnumeric_iferror): New function.



Modified:
   branches/gnumeric-1-8/NEWS
   branches/gnumeric-1-8/plugins/fn-logical/ChangeLog
   branches/gnumeric-1-8/plugins/fn-logical/functions.c
   branches/gnumeric-1-8/plugins/fn-logical/plugin.xml.in

Modified: branches/gnumeric-1-8/NEWS
==============================================================================
--- branches/gnumeric-1-8/NEWS	(original)
+++ branches/gnumeric-1-8/NEWS	Fri Apr 11 23:52:11 2008
@@ -20,6 +20,7 @@
 	  data range.  [#525875]
 	* Fix date pasting problems to/from 1904 workbooks.  [#490419]
 	* Fix problems editing times.  [#527392]
+	* Implement IFERROR.  [#445591]
 
 --------------------------------------------------------------------------
 Gnumeric 1.8.2

Modified: branches/gnumeric-1-8/plugins/fn-logical/functions.c
==============================================================================
--- branches/gnumeric-1-8/plugins/fn-logical/functions.c	(original)
+++ branches/gnumeric-1-8/plugins/fn-logical/functions.c	Fri Apr 11 23:52:11 2008
@@ -305,6 +305,23 @@
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_iferror[] = {
+	{ GNM_FUNC_HELP_NAME, F_("IFERROR:Test for error.") },
+	{ GNM_FUNC_HELP_ARG, F_("x:value to test for error.") },
+	{ GNM_FUNC_HELP_ARG, F_("y:alternate value.") },
+	{ GNM_FUNC_HELP_DESCRIPTION, F_("This function returns the first value, unless that is an error, in which case it returns the second.") },
+	{ GNM_FUNC_HELP_SEEALSO, "IF,ISERROR" },
+	{ GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_iferror (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+	return value_dup (VALUE_IS_ERROR (argv[0]) ? argv[1] : argv[0]);
+}
+
+/***************************************************************************/
+
 static GnmFuncHelp const help_true[] = {
 	{ GNM_FUNC_HELP_OLD,
 	F_("@FUNCTION=TRUE\n"
@@ -372,6 +389,9 @@
 	  gnumeric_if, NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE + GNM_FUNC_AUTO_SECOND,
 	  GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+	{ "iferror", "EE", N_("value,value"), help_iferror,
+	  gnumeric_iferror, NULL, NULL, NULL, NULL,
+	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
 	{ "true", "", "", help_true, gnumeric_true,
 	  NULL, NULL, NULL, NULL,
 	  GNM_FUNC_SIMPLE + GNM_FUNC_AUTO_UNITLESS,

Modified: branches/gnumeric-1-8/plugins/fn-logical/plugin.xml.in
==============================================================================
--- branches/gnumeric-1-8/plugins/fn-logical/plugin.xml.in	(original)
+++ branches/gnumeric-1-8/plugins/fn-logical/plugin.xml.in	Fri Apr 11 23:52:11 2008
@@ -16,6 +16,7 @@
 				<function name="xor"/>
 				<function name="not"/>
 				<function name="if"/>
+				<function name="iferror"/>
 				<function name="true"/>
 				<function name="false"/>
 			</functions>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]