////////// // // Function: VARTYPE() // Returns the variable type, parsing NULL values. // ////// // Version 0.58 // Last update: // Apr.06.2015 ////// // Change log: // Apr.06.2015 - Initial creation ////// // Parameters: // P1 -- The variable to examine // P2 -- (Optional) If provided, .t. or .f. indicating if NULL values should return the type (default to .f.) // ////// // Returns: // Character -- A one-digit value indicating the type ////// void function_vartype(SReturnsParams* rpar) { SVariable* var = rpar->ip[0]; SVariable* varNull = rpar->ip[1]; bool llNullIsType; bool error; u32 errorNum; ////////// // varLookup must exist ////// rpar->rp[0] = NULL; if (!iVariable_isValidType(var)) { iError_report_byNumber(_ERROR_P1_IS_INCORRECT, iVariable_get_relatedComp(var), false); return; } ////////// // If varNull is specified, must be logical ////// if (varNull) { ////////// // Must be logical ////// if (!iVariable_isValid(varNull) || !iVariable_isTypeLogical(varNull)) { iError_report_byNumber(_ERROR_P2_IS_INCORRECT, iVariable_get_relatedComp(varNull), false); return; } ////////// // Grab the value ////// llNullIsType = iiVariable_getAs_bool(varNull, false, &error, &errorNum); if (error) { iError_report_byNumber(errorNum, iVariable_get_relatedComp(varNull), false); return; } } else { // Do not report on NULL types llNullIsType = false; } ////////// // Compute our result ////// ifunction_type_common(rpar, var, false, true, llNullIsType); }
////////// // // 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); }