We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Writing a custom logical function

Thread ID:

Created:

Updated:

Platform:

Replies:

26537 Mar 24,2005 04:56 PM UTC Mar 25,2005 09:09 PM UTC Windows Forms 4
loading
Tags: Calculate
Brad King
Asked On March 24, 2005 04:56 PM UTC

How would I write a function who''s return value can be evaluated by the IF statement you provide ? I''m a little confused, since the signature for custom functions always returns a string. Is the string TRUE and FALSE actually evaluated as a logical values or is there a boolean type you use internally for this thats not available for custom functions ?

Administrator [Syncfusion]
Replied On March 25, 2005 02:33 AM UTC

The string TRUE is recognized as the true logical value. So, if you have the formula if(TRUE,1,0) you will see 1 as the calculated value. In this sample, \Syncfusion\Essential Suite\3.0.1.0\Windows\Calculate.Windows\Samples\DataGridCalculator, if you replace the definition of the custom function with this code,
public string ComputeMymin(string args)
{	
	if(args == "1")
		return "TRUE";
	else
		return "FALSE";
}
you can then type this formula in the textbox = IF(mymin(1),18,20) then you will see 18 displayed.

Brad King
Replied On March 25, 2005 02:57 PM UTC

Interesting. Thanks Clay. Having not used Excel style functions much this seems very strange, but workable. >The string TRUE is recognized as the true logical value. So, if you have the formula > >if(TRUE,1,0) > >you will see 1 as the calculated value. > >In this sample, \Syncfusion\Essential Suite\3.0.1.0\Windows\Calculate.Windows\Samples\DataGridCalculator, if you replace the definition of the custom function with this code, >
>public string ComputeMymin(string args)
>{	
>	if(args == "1")
>		return "TRUE";
>	else
>		return "FALSE";
>}
>
>you can then type this formula in the textbox > >= IF(mymin(1),18,20) > >then you will see 18 displayed.

Brad King
Replied On March 25, 2005 03:21 PM UTC

Actually there is one more issue of confusion for me on this. Is there any difference between "TRUE" and TRUE ? Do all strings need to be in quotes, except TRUE and FALSE ? >The string TRUE is recognized as the true logical value. So, if you have the formula > >if(TRUE,1,0) > >you will see 1 as the calculated value. > >In this sample, \Syncfusion\Essential Suite\3.0.1.0\Windows\Calculate.Windows\Samples\DataGridCalculator, if you replace the definition of the custom function with this code, >
>public string ComputeMymin(string args)
>{	
>	if(args == "1")
>		return "TRUE";
>	else
>		return "FALSE";
>}
>
>you can then type this formula in the textbox > >= IF(mymin(1),18,20) > >then you will see 18 displayed.

Administrator [Syncfusion]
Replied On March 25, 2005 09:09 PM UTC

How are you trying to use Essential Calculate? If you are trying to use CalcQuick, then if you do not use ''extra'' quotes when you set a string into a variable. But you do include the quotes when you use the string in as part of a formula expression. For example, in the \Syncfusion\Essential Suite\3.0.1.0\Windows\Calculate.Windows\Samples\FirstSample Algebraic expression sample, you can enter the letter a as the variable name, and the word test as the variable value and then click Set Variable to set the variable a to be the string test. Then in the Algebraic expression textbox, you would type [a]="test" and press Compute to see this computed value which will be TRUE. If you are using an ICalcData object like one of the DataGrid samples we ship, you could enter just the word test into say cell A3. Then in another cell, you could type = A3="test" to display whether A3 contained test. So, in general, you only need the quotes around strings when you are entering formulas.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;