Esempio n. 1
0
//////////
//
// Function: EMPTY()
// Determines whether an expression evaluates to empty.
//
//////
// Version 0.58
// Last update:
//     Mar.20.2015
//////
// Change log:
//     Mar.20.2015 - Refactoring by Stefano D'Amico
//     Mar.19.2015 - Refactoring by Rick C. Hodgin
//     Mar.19.2015 - Initial creation by Stefano D'Amico
//////
// Parameters:
//     p1	-- Specifies the expression that EMPTY( ) evaluates.
//
//////
// Returns:
//    EMPTY( ) returns True (.T.) if the expression eExpression evaluates to empty;
//    otherwise, EMPTY( ) returns False (.F.)
//////
// Example:
//    ? EMPTY("AA")	&& Display .F.
//    ? EMPTY("  ")	&& Display .T.
//    ? EMPTY(0.0)	&& Display .T.
//////
	void function_empty(SReturnsParams* rpar)
	{
		SVariable*	varExpr = rpar->ip[0];
		bool		llEmpty;
		SVariable*	result;


		//////////
		// Verify the expression is correct
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValid(varExpr))
			{
				iError_report_byNumber(_ERROR_PARAMETER_IS_INCORRECT, iVariable_get_relatedComp(varExpr), false);
				return;
			}


		//////////
		// Create and populate the return variable
		//////
			llEmpty	= function_isempty_common(rpar, varExpr);
			result	= iVariable_createAndPopulate_byText(_VAR_TYPE_LOGICAL, iVariable_populate_byBool(llEmpty), 1, false);
			if (!result)
				iError_report_byNumber(_ERROR_INTERNAL_ERROR, iVariable_get_relatedComp(varExpr), false);


		//////////
		// Signify our result
		//////
			rpar->rp[0] = result;

	}
Esempio n. 2
0
//////////
//
// Function: EMPTY()
// Determines whether an expression evaluates to empty.
//
//////
// Version 0.57
// Last update:
//     Mar.20.2015
//////
// Change log:
//     Mar.20.2015 - Refactoring by Stefano D'Amico
//     Mar.19.2015 - Refactoring by Rick C. Hodgin
//     Mar.19.2015 - Initial creation by Stefano D'Amico
//////
// Parameters:
//     p1	-- Specifies the expression that EMPTY( ) evaluates.
//
//////
// Returns:
//    EMPTY( ) returns True (.T.) if the expression eExpression evaluates to empty;
//    otherwise, EMPTY( ) returns False (.F.)
//////
// Example:
//    ? EMPTY("AA")	&& Display .F.
//    ? EMPTY("  ")	&& Display .T.
//    ? EMPTY(0.0)	&& Display .T.
//////
	void function_empty(SThisCode* thisCode, SFunctionParms* rpar)
	{
		SVariable*	varExpr = rpar->params[0];
		bool		llEmpty;
		SVariable*	result;


		//////////
		// Verify the expression is correct
		//////
			rpar->returns[0] = NULL;
			if (!iVariable_isValid(varExpr))
			{
				iError_reportByNumber(thisCode, _ERROR_PARAMETER_IS_INCORRECT, iVariable_getRelatedComp(thisCode, varExpr), false);
				return;
			}


		//////////
		// Create and populate the return variable
		//////
			llEmpty	= function_isempty_common(thisCode, rpar, varExpr);
			result	= iVariable_createAndPopulate_byText(thisCode, _VAR_TYPE_LOGICAL, (cs8*)((llEmpty) ? &_LOGICAL_TRUE : &_LOGICAL_FALSE), 1, false);
			if (!result)
				iError_reportByNumber(thisCode, _ERROR_INTERNAL_ERROR, iVariable_getRelatedComp(thisCode, varExpr), false);


		//////////
		// Signify our result
		//////
			rpar->returns[0] = result;

	}
Esempio n. 3
0
//////////
//
// Function: EVL()
// Returns a non-empty value from two expressions.
//
//////
// Version 0.58
// Last update:
//     Mar.20.2015
//////
// Change log:
//     Mar.20.2015 - Some refactoring by Rick C. Hodgin
//     Mar.20.2015 - Initial creation by Stefano D'Amico
//////
// Parameters:
//     p1	-- Specifies the expression that EMPTY( ) evaluates.
//     p2	-- Specifies the expression to return if p1 is empty.
//
//////
// Returns:
//    EVL( ) returns p1 if it does not evaluate to an empty value; otherwise, it returns p2.
//////
// Example:
//    ? EVL("  ", "None")	&& Display "None"
//////
	void function_evl(SReturnsParams* rpar)
	{
		SVariable*	varExpr1 = rpar->ip[0];
		SVariable*	varExpr2 = rpar->ip[1];
		bool		llEmpty;
		SVariable*	result;


		//////////
		// Verify p1 is correct
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValid(varExpr1))
			{
				iError_report_byNumber(_ERROR_P1_IS_INCORRECT, iVariable_get_relatedComp(varExpr1), false);
				return;
			}


		//////////
		// Verify p2 is correct
		//////
			if (!iVariable_isValid(varExpr2))
			{
				iError_report_byNumber(_ERROR_P2_IS_INCORRECT, iVariable_get_relatedComp(varExpr2), false);
				return;
			}


		//////////
		// Create our result
		//////
			llEmpty	= function_isempty_common(rpar, varExpr1);
			result	= iVariable_copy(((llEmpty) ? varExpr2 : varExpr1), false);
			if (!result)
				iError_report_byNumber(_ERROR_INTERNAL_ERROR, iVariable_get_relatedComp(((llEmpty) ? varExpr2 : varExpr1)), false);


		//////////
		// Signify our result
		//////
			rpar->rp[0] = result;

	}