Beispiel #1
0
//////////
//
// Function: ISNULL()
// Determines whether an expression evaluates to null.
//
//////
// Version 0.58
// Last update:
//     Apr.22.2015
//////
// Change log:
//     Apr.06.2015 - Initial creation by Hernan Cano M
//////
// Parameters:
//     p1	-- Specifies the expression that ISNULL() evaluates.
//
//////
// Returns:
//    ISNULL() returns True (.T.) if the expression eExpression evaluates to null;
//    otherwise, ISNULL() returns False (.F.)
//////
// Example:
//    ? ISNULL("AA")	&& Display .F.
//    ? ISNULL("  ")	&& Display .F.
//    ? ISNULL(0.0)  	&& Display .F.
//    ? ISNULL(.null.)  && Display .T.
//////
	void function_isnull(SReturnsParams* rpar)
	{
		SVariable*	varExpr = rpar->ip[0];

		bool		llIsNull;


		//////////
		// Verify the variable is of a valid format
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValidType(varExpr))
			{
				iError_report_byNumber(_ERROR_PARAMETER_IS_INCORRECT, iVariable_get_relatedComp(varExpr), false);
				return;
			}


		//////////
		// Create and populate the return variable
		//////
			llIsNull	= ifunction_isnull_common(varExpr);
			rpar->rp[0]	= iVariable_createAndPopulate_byText(_VAR_TYPE_LOGICAL, iVariable_populate_byBool(llIsNull), 1, true);
			if (!rpar->rp[0])
				iError_report_byNumber(_ERROR_INTERNAL_ERROR, iVariable_get_relatedComp(varExpr), false);

	}
Beispiel #2
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;

	}
Beispiel #3
0
//////////
//
// Function: ISUPPER()
// Determines whether the first character in a character expression is an uppercase alphabetic character.
//
//////
// Version 0.58
// Last update:
//     Sep.15.2015
//////
// Change log:
//     Sep.15.2015 - Initial creation by Stefano D'Amico
//////
// Parameters:
//     p1	-- Specifies the character expression that ISUPPER( ) evaluates.
//     p2	-- Optional, if true evaluates all string
//
//////
// Returns:
//    ISUPPER( ) returns true (.T.) if the first character in a character expression is an uppercase alphabetic character;
//    otherwise, ISUPPER( ) returns false (.F.).
//////
// Example:
//    ? ISUPPER("Aa")		&& Display .T.
//    ? ISUPPER("Aa")		&& Display .T.
//    ? ISUPPER("Aa", .T.) 	&& Display .F.
//    ? ISUPPER("AA", .T.)	&& Display .T.
//////
	void function_isupper(SReturnsParams* rpar)
	{
		SVariable*	varStr				= rpar->ip[0];
		SVariable*	varTestWholeString	= rpar->ip[1];

		bool		llTestWholeString, llIsUpper;
		bool		error;
		u32			errorNum;


		//////////
		// Parameters 1 must be present and character
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValid(varStr) || !iVariable_isTypeCharacter(varStr))
			{
				iError_report_byNumber(_ERROR_P1_IS_INCORRECT, iVariable_get_relatedComp(varStr), false);
				return;
			}


		//////////
		// If present, parameter 2 must be bool
		//////
			if (varTestWholeString)
			{
				if (!iVariable_isFundamentalTypeLogical(varTestWholeString))
				{
					iError_report_byNumber(_ERROR_P2_IS_INCORRECT, iVariable_get_relatedComp(varTestWholeString), false);
					return;
				}

				// Grab the value
				llTestWholeString = iiVariable_getAs_bool(varTestWholeString, false, &error, &errorNum);
				if (error)
				{
					iError_report_byNumber(errorNum, iVariable_get_relatedComp(varTestWholeString), false);
					return;
				}

			} else {
				// Just testing the first character
				llTestWholeString = false;
			}


		//////////
		// Create and populate the return variable
		//////
			llIsUpper	= ifunction_iscommon(varStr, llTestWholeString, _isUpper);
			rpar->rp[0]	= iVariable_createAndPopulate_byText(_VAR_TYPE_LOGICAL, iVariable_populate_byBool(llIsUpper), 1, true);
			if (!rpar->rp[0])
				iError_report_byNumber(_ERROR_INTERNAL_ERROR, iVariable_get_relatedComp(varStr), false);

	}
Beispiel #4
0
//////////
//
// Function: _VJRSYS()
// Internal function.  Not published.  Used to access VJr system variables.
//
//////
// Version 0.58
// Last update:
//     Oct.28.2015
//////
// Change log:
//     Oct.28.2015 - Initial creation by Rick C. Hodgin
//////
// Parameters:
//     varIndex			-- Index function to access the variable
//
//////
// Returns:
//     Varies			-- Based on index, returns the VJr system variable
//////
	void function__vjrsys(SReturnsParams* rpar)
	{
		SVariable* varIndex		= rpar->ip[0];

		s32			lnIndex;
		u32			errorNum;
		bool		error;


		//////////
		// Parameter 1 must be valid and numeric
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValid(varIndex) || !iVariable_isTypeNumeric(varIndex))
			{
				iError_report_byNumber(_ERROR_P1_IS_INCORRECT, iVariable_get_relatedComp(varIndex), false);
				return;
			}

			// Grab the index value
			lnIndex = iiVariable_getAs_s32(varIndex, false, &error, &errorNum);
			if (error)
			{
				iError_report_byNumber(errorNum, iVariable_get_relatedComp(varIndex), false);
				return;
			}


		//////////
		// Dispatch based on operation
		//////
			switch (lnIndex)
			{
				case 1:
					rpar->rp[0] = iVariable_createAndPopulate_byText(_VAR_TYPE_LOGICAL, iVariable_populate_byBool(glShuttingDown), 1, false);
					break;

				default:
					iError_report_byNumber(_ERROR_FEATURE_NOT_AVAILABLE, iVariable_get_relatedComp(varIndex), false);
					break;
			}

	}
Beispiel #5
0
//////////
//
// Function: INLIST()
// A test if the value is in the list.
//
//////
// Version 0.58
// Last update:
//     Mar.22.2015
//////
// Change log:
//     Mar.22.2015 - Initial creation
//////
// Parameters:
//     varValue		-- The value to compare
//     varList1		-- A value in the list
//     varList2		-- A value in the list
//     ..
//     varList9		-- A value in the list
//
//////
// Returns:
//    Logical		-- .t. if the item is found in the list, .f. otherwise
//////
	void function_inlist(SReturnsParams* rpar)
	{
		SVariable*	varValue = rpar->ip[0];
		SVariable*	varList1 = rpar->ip[1];
		bool		llResult;
		s32			lnI, lnType;
		SVariable*	result;
		u32			errorNum;
        bool		error;


		//////////
		// Parameters 1 and 2 must be present, and of equal types
		//////
			rpar->rp[0] = NULL;
			if (!iVariable_isValid(varValue))
			{
				iError_report_byNumber(_ERROR_MISSING_PARAMETER, iVariable_get_relatedComp(varValue), false);
				return;
			}
			if (!iVariable_isValid(varList1))
			{
				iError_report_byNumber(_ERROR_MISSING_PARAMETER, iVariable_get_relatedComp(varList1), false);
				return;
			}


		//////////
		// Each type must be fundamentally the same type
		//////
			for (lnI = 1, lnType = iVariable_get_fundamentalType(varValue); lnI < (s32)_MAX_PARAMS_COUNT && rpar->ip[lnI]; lnI++)
			{

				//////////
				// Make sure this variable type matches the test value
				//////
					if (iVariable_get_fundamentalType(rpar->ip[lnI]) != lnType)
					{
						// The types do not match
						iError_report_byNumber(_ERROR_DATA_TYPE_MISMATCH, iVariable_get_relatedComp(rpar->ip[lnI]), false);
						return;
					}

			}


		//////////
		// Iterate through to see if the parameters are equal
		//////
			for (lnI = 1, llResult = false; lnI < (s32)_MAX_PARAMS_COUNT && rpar->ip[lnI]; lnI++)
			{

				//////////
				// Compare the value with each list item
				//////
					if (iVariable_compare(varValue, rpar->ip[lnI], false, &error, &errorNum) == 0 && !error)
					{
						// We found a match
						llResult = true;
						break;
					}


				//////////
				// Report on errors
				//////
					if (error)
					{
						iError_report_byNumber(errorNum, iVariable_get_relatedComp(rpar->ip[lnI]), false);
						return;
					}

			}


		//////////
		// Based on the result, create the return(result)
		//////
			result = iVariable_createAndPopulate_byText(_VAR_TYPE_LOGICAL, iVariable_populate_byBool(llResult), 1, false);
			if (!result)
				iError_report_byNumber(_ERROR_INTERNAL_ERROR, iVariable_get_relatedComp(varValue), false);


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

	}