_RetVal( ) API Library Routine

Returns any Visual FoxPro data type, except Memo.

void _RetVal(Value FAR *val)
Value FAR *val;            /* Pointer to value structure. */

Remarks

_RetVal( ) passes a complete Visual FoxPro Value structure. You must call _RetVal( ) to return a string that contains embedded null characters.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example uses _RetVal( ) to return its Character-type parameter converted to uppercase.

Visual FoxPro Code

SET LIBRARY TO RETVAL  
? XUPPER("upper")  && returns "UPPER"

C Code

#include "pro_ext.h"

void NullTerminate(Value FAR *cVal)
{
   if (!_SetHandSize(cVal->ev_handle, cVal->ev_length + 1)) {
      _Error(182); // "Insufficient memory"
   }
   ((char FAR *) _HandToPtr(cVal->ev_handle))[cVal->ev_length] = '\0';
}

FAR Example(ParamBlk FAR *parm)
{
   char FAR *pString;
   int i;

   NullTerminate(&parm->p[0].val);
   pString = _HandToPtr(parm->p[0].val.ev_handle);
   for (i = 0; i < parm->p[0].val.ev_length; i++)
   {
      if ('a' <= *pString && *pString <= 'z')
      {
         *pString += ('A' - 'a');
      }
      pString++;
   }
   _RetVal(&parm->p[0].val);
}

FoxInfo myFoxInfo[] = {
   {"XUPPER", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_RetChar( ) API Library Routine | _RetCurrency( ) API Library Routine | _RetDateStr( ) API Library Routine | _RetDateTimeStr( ) API Library Routine | _RetFloat( ) API Library Routine | _RetInt( ) API Library Routine | _RetLogical( ) API Library Routine