Shiny Language Reference

Language Reference > File Functions


freadbytes

bool freadbytes(file FileVar, string Dest, int Bytes);

 

 

Reads N bytes from a file

The FREADBYTES statement reads a specified number of a bytes from a file previously opened by FOPEN. The advantage of using this statement instead of FREADLINE is that CRLF characters can be read from the file. It is also more compatible with FSEEK.

 

Parameters

FileVar

A variable declared as type FILE which has previously been associated with a file by using FOPEN.

Dest

A string variable that receives the line of text read from the file.

Bytes

An integer specifying the number of bytes to read from the file.

 

Return Value

TRUE if reading from the file suceeded and there is further data left in the file. Testing for FALSE is used to determine if the end of the file has been reached.

 

Example Code

file myfile;

if(fopen(myfile, "C:\\Readme.txt") == FALSE)
{
    bool bMoreData = TRUE;
    
    while(bMoreData)
    {
        // DataIn receives text from the file, 4 bytes at a time
        string DataIn;
        bMoreData = freadbytes(myfile, DataIn, 4);
    }
}