Compartir a través de


_MemoChan( ) API Library Routine

Returns the file channel of the memo file associated with the specified workarea.

FCHAN _MemoChan(int workarea)
int workarea;               /* Work area number. */

Remarks

If no database is open in that work area or the database has no memo file, _MemoChan( ) returns – 1.

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 retrieves the contents of a memo field. _MemoChan( – 1) returns a file channel to the memo file for the current work area. This FCHAN is used as an argument to the low-level file I/O API callbacks.

Visual FoxPro Code

SET LIBRARY TO MEMOCHAN
CREATE TABLE WMemo (MemoField M)
APPEND BLANK
REPLACE MemoField WITH "Hello, World."
? GETMEMO(@MemoField)

C Code

#include <pro_ext.h>

FAR FindMemoEx(ParamBlk FAR *parm)
{
   Locator FAR *memoFldLoc;
   FCHAN fchMemo;
   char FAR *memoContents;
   int memoLen;
   long loc;

   if ((fchMemo = _MemoChan(-1)) == -1)
   {
      _UserError("_MemoChan() failed");
   }
   memoFldLoc = &parm->p[0].loc;

   if ((loc = _FindMemo(memoFldLoc)) < 0)
   {
      _UserError("_FindMemo() failed");
   }
   if ((memoLen = _MemoSize(memoFldLoc)) < 0)
   {
      _UserError("_MemoSize() failed");
   }
   if ((memoContents = _Alloca(memoLen + 1)) == 0)
   {
      _Error(182); // "Insufficient memory"
   }
   _FSeek(fchMemo, loc, FS_FROMBOF);
   _FRead(fchMemo, memoContents, memoLen);
   memoContents[memoLen] = '\0';
   _RetChar(memoContents);
}

FoxInfo myFoxInfo[] = {
   {"GETMEMO", (FPFI) FindMemoEx, 1, "R"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Concepts

API Library Routines A-Z

Reference

_AllocMemo( ) API Library Routine

_DBReplace( ) API Library Routine

_FindMemo( ) API Library Routine

_FOpen( ) API Library Routine

_MemoSize( ) API Library Routine

Other Resources

Accessing the Visual FoxPro API

API Library Routines by Category