Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Function 42H (decimal 66) changes the logical read/write position in a
  file. To invoke this service, load BX with a handle and then specify the
  new pointer location by placing a reference location in AL and an offset
  relative to the reference location in register pair CX:DX. The byte offset
  in CX:DX is a 32-bit, long integer. CX is the high-order part of the
  offset (which is 0, unless the offset amount is more than 65,535) and DX
  is the low-order part.

  You can specify the reference location in AL in three different ways: If
  AL = 00H, the offset is taken relative to the beginning of the file and
  the file pointer is moved CX:DX bytes from that point; if AL = 01H, the
  offset is taken relative to the current file pointer location; if AL =
  02H, the offset is taken from the current end of file.

  If the function executes successfully, it clears the carry flag and
  returns in the register pair DX:AX the current file pointer location
  relative to the beginning of the file. The pointer is returned as a 32-bit
  long integer, with the high-order part in DX and the low-order part in AX.
  If the function fails, it sets the carry flag and returns an error code in
  AX. Possible error codes are 01H (invalid function number, which means AL
  did not contain 00H, 01H, or 02H) and 06H (invalid handle).

  You can use function 42H in several different ways:

  .  To place the file pointer at an arbitrary location in the file, call
     function 42H with AL = 00H and CX:DX specifying the desired offset
     relative to the start of the file.

  .  To position the file pointer at the end of the file, call function 42H
     with AL = 02H and 00H in CX:DX.

  .  To determine the current location of the file pointer, use AL = 01H and
     00H in CX:DX; the value returned in DX:AX is the current file pointer
     location.

  DOS does not validate the resulting location of the file pointer. In
  particular, you can end with a negative file pointer offset (that is, a
  file pointer at a position before the logical start of the file). However,
  it's not a good idea to use negative file pointers for two reasons: If you
  perform a subsequent read or write operation, you'll be in error; and your
  program will be harder to adapt for OS/2, where an attempt to move a file
  pointer to a negative offset generates an error.

  --------------------------------------------------------------------------
  NOTE:
    The operation of moving a logical file pointer to a specified location
    in a file is sometimes called a "seek," but the same word is also used
    in the sense of moving the read/write heads of a disk drive to a
    specified cylinder on a disk. The two operations aren't the same.
  --------------------------------------------------------------------------

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson