Function RecSize() Foundation

Returns the length of a record in a work area.

RecSize() --> nBytes

The return value of RecSize() is a integer numeric value indicating the length of a record in a work area (in number of bytes). When no table is used in the specified work area, the value zero is returned.


The table function RecSize() returns the number of bytes taken up by a record in a work area. A table must be open in a work area. When the function is used without the alias operator, it returns the record length for the current work area. RecSize() returns the sum of all field lengths. For DBF files the current length of a record is RecSize() + 1, since each record includes a byte reserved for indicating "deleted" status (the Deleted() flag).

With ISAM/DBF tables this function is used with LastRec() and Header() to determine the size of an open DBF file. The file size may be needed for back-up routines creating copies of DBF files, for example.

With SQL result sets the function RecSize() returns an average of bytes used by a single record in memory. The SQL LIMIT clause can be used to restrict the amount of records hold im memory.

// In the example, a UDF is shown which determines 
// the size of a DBF file. 

   USE Customer NEW 

   ? Header()                  // result: 224 
   ? RecSize()                 // result: 184 
   ? LastRec()                 // result: 100 

   ? DbfFileSize()             // result: 18625 


FUNCTION DbfFileSize() 
RETURN ( (RecSize() * LastRec()) + Header() + 1 ) 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.