_FRead( ) (Rutina de biblioteca API)
Copia, desde un archivo al búfer especificado por buffer, tantos bytes como indique length.
unsigned int _FRead(FCHAN chan, char FAR *buffer, int length)
FCHAN chan; /* File channel of file from which to copy. */
char FAR *buffer; /* Buffer address. */
int length; /* Number of bytes to be copied. */
Observaciones
_FRead( ) no anexa ningún terminador al final de los bytes del búfer. No se realiza ninguna conversión en los bytes cuando se almacenan en el búfer. _FRead( ) devuelve el número de bytes leídos.
Para obtener más información acerca de cómo crear una biblioteca API e integrarla con Visual FoxPro, vea Acceso a la API de Visual FoxPro.
Ejemplo
El siguiente ejemplo crea un archivo de prueba e inserta texto en él. A continuación, el ejemplo intenta leer 32 bytes del archivo mediante _FRead( ).
Código Visual FoxPro
SET LIBRARY TO FREAD
Código C
#include <pro_ext.h>
#define BUFFSIZE 32
static char buffer[BUFFSIZE];
FAR Example(ParamBlk FAR *parm)
{
FCHAN fchan;
int bytesRead;
fchan = _FCreate("temp.tmp", FC_NORMAL);
_FPuts(fchan, "Hello, world.");
_FPuts(fchan, "Hello, world.");
_FPuts(fchan, "Hello, world.");
_FPuts(fchan, "Hello, world.");
_FPuts(fchan, "Hello, world.");
_FSeek(fchan, 0, FS_FROMBOF);
bytesRead = _FRead(fchan, buffer, BUFFSIZE - 1);
buffer[bytesRead] = '\0';
_PutStr(buffer);
_FClose(fchan);
}
FoxInfo myFoxInfo[] = {
{"FREAD", (FPFI) Example, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
Vea también
_FGets( ) (Rutina de biblioteca API) | _FSeek( ) (Rutina de biblioteca API) | Acceso a la API de Visual FoxPro