@@ -2029,8 +2029,8 @@ bool iszero = ((requested.flags & GDL_KW_ZERO) == GDL_KW_ZERO); //zero field if
2029
2029
// and GDL_KW_OUT | GDL_KW_ZERO for the flags. The value field will either
2030
2030
// contain NULL or the pointer to the variable. */
2031
2031
bool inputByReference = ((requested.flags & GDL_KW_VIN) == GDL_KW_VIN); // input, but passed by reference
2032
- bool isoutput = (!inputByReference && (requested.flags & GDL_KW_OUT) == GDL_KW_OUT);
2033
- bool isarray = (!inputByReference && (requested.flags & GDL_KW_ARRAY) == GDL_KW_ARRAY); // var must be an array, field is a GDL_KW_ARR_DESC_R*
2032
+ bool isoutput = ((requested.flags & GDL_KW_OUT) == GDL_KW_OUT);
2033
+ bool isarray = ((requested.flags & GDL_KW_ARRAY) == GDL_KW_ARRAY); // var must be an array, field is a GDL_KW_ARR_DESC_R*
2034
2034
bool byMask = ((requested.flags & GDL_KW_VALUE) == GDL_KW_VALUE);
2035
2035
// tag 'out' those that will get a return value
2036
2036
if (requested.specified != NULL ) { // need write 0 or 1 in a special int in KW structure
@@ -2044,7 +2044,7 @@ if (requested.value != NULL) { // need to pass either an address of a EXPORT_VPT
2044
2044
if (isoutput && passed.readonly ) GDL_WillThrowAfterCleaning (" Keyword " + std::string (requested.keyword ) + " must be a named variable." );
2045
2045
BaseGDL* var = passed.varptr ;
2046
2046
// if requested var is NULL here, it is an undefined var, which MAY be returned as good value.
2047
- if (var == NULL ) GDL_WillThrowAfterCleaning (" GDLExportKeyword: variable " + std::string (requested.keyword ) + " is not defined." );
2047
+ if (var == NULL && !isoutput ) GDL_WillThrowAfterCleaning (" GDLExportKeyword: variable " + std::string (requested.keyword ) + " is not defined." );
2048
2048
if (iszero) { // zero before write.
2049
2049
GDLZeroAtAddr (global_address);
2050
2050
}
@@ -2084,6 +2084,9 @@ if (requested.value != NULL) { // need to pass either an address of a EXPORT_VPT
2084
2084
}
2085
2085
}
2086
2086
}
2087
+ } else if (isoutput) {
2088
+ toBeReturned = IDL_Gettmp ();
2089
+ memcpy ((void *) (global_address), (void *) (&toBeReturned), sizeof (EXPORT_VPTR)); // pass address of a EXPORT_VAR that will contain the result.
2087
2090
}
2088
2091
}
2089
2092
return toBeReturned;
0 commit comments