The LazyBoy Library Manual - FileSize

Part of the File group.

%imacro FileSize 2
Prefers: DX:AX, BX

Return the current file size for a file handle. If successful CF will be clear and the file size will be returned. On error, the CF will be set, DX will be 0 and AX will be the error code. Also, the IO_ERROR value will be updated.

This function may also be used with the Text Writer when writing to a memory buffer to determine the byte size of the buffer. The Text Writer must be assigned to the same output requested by FileSize or an error will be returned. Sequential character writing devices (like wdCONSOLE) always return 0 as their size.

  • %1 is Register Pair or Memory Reference
  • %2 is File Handle

Examples:

    FileSize dx:ax,bx        ; return 32-bit file size register pair.
    FileSize [di], bx        ; store 32-bit file size at [DS:DI]
    FileSize dx:ax, wdMEMORY ; return capacity of Text Writer buffer.

See also FilePos, FileSeek and IO_ERROR.