Returns a comparison expression comparison result or a function that calculates the expression value.

Source: Internet
Author: User

Expression

 

Comparison expression functions:
C/C ++ code
// ================================================ ====================================
// Function: f_exp_compare
//--------------------------------------------------------------------
// Description: returns the comparison result of the comparison expression.
//--------------------------------------------------------------------
// Parameters:
// Value string as_str calculation expression, for example, 60 <70
//--------------------------------------------------------------------
// Return value: String comparison indicates that result 1 of the test is true, 0 is false, and-1 is an expression error.
// ================================================ ====================================
String ls_retval
Datastore lds_evaluate
Lds_evaluate = create datastore
Lds_evaluate.create ('release 8 ;~ R ~ Ntable ()')
Ls_retval = lds_evaluate.describe ("evaluate ('" + "If (" + as_str + ", 1, 0)" + "', 1 )")
Destroy lds_evaluate
If ls_retval = '! 'Then ls_retval = '-1'
Return ls_retval

Function used to calculate the expression value:
C/C ++ code
// ================================================ ====================================
// Function: f_exp_ret
//--------------------------------------------------------------------
// Description: return the value of the calculated expression.
//--------------------------------------------------------------------
// Parameters:
// Value string as_str calculation expression, such as 2*(3 + 5)
//--------------------------------------------------------------------
// Return value: String calculates the result value of the expression. If the expression is incorrect, 'false' is returned'
// ================================================ ====================================
String ls_retval
Datastore lds_evaluate
Lds_evaluate = create datastore
Lds_evaluate.create ('release 8 ;~ R ~ Ntable ()')
Ls_retval = lds_evaluate.describe ("evaluate ('" + as_str + "', 1 )")
Destroy lds_evaluate
If ls_retval = ''or ls_retval = '! 'Then ls_retval = 'false'
Return ls_retval

Example:
C/C ++ code
String ls_exp1, ls_exp2, ls_ret1, ls_ret2

Ls_exp1 = '69 <70'
Ls_ret1 = f_exp_compare (ls_exp1)
Ls_exp2 = '60*(20 + 3 )'
Ls_ret2 = f_exp_ret (ls_exp2)
MessageBox ('', ls_exp1 + '-->' + ls_ret1 + '~ R ~ N' + &
Ls_exp2 + '-->' + ls_ret2)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.