Click or drag to resize

RecSize Function

X#
Determine the record length of a database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION RecSize() AS LONG
Request Example View Source

Return Value

Type: Long
The record length, in bytes. RecSize() returns 0 if no database file is open.
Remarks
RecSize() determines the length of a record by summing the lengths of each field, then adding one for the Deleted() status flag. When this value is multiplied by LastRec(), the product is the amount of space occupied by all of the file's records. RecSize() is useful in programs that perform automatic file backup. When used in conjunction with DiskSpace(), the RecSize() function can assist in ensuring that sufficient free space exists on the disk before a file is stored.
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying it within an aliased expression or by calling the overload that accepts a workarea parameter (a workarea number or alias ).
Examples
The following function, DBFSize(), uses RecSize() to calculate the size of the current database file:
X#
1FUNCTION DBFSize
2    RETURN ((RecSize() * LastRec()) + Header() + 1)
This example illustrates the use of RecSize() to determine the record length of database files open in unselected work areas:
X#
1USE customer NEW
2USE sales NEW
3QOut(RecSize(), Customer->RecSize())
4QOut(DBFSize(), Customer->DBFSize())
See Also