home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ; dosrando.asm
- ; contains: dosrdrrec(),doswtrrec(),dosrdrblk(),doswtrblk()
- ;
- ;
- ; MODIFICATIONS
- ;
- include model.h
- include prologue.h
- include equ.h
- name dosrando
- pseg dosrando
-
- ;==>-- int dosrdrrec(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to disktable structure
- ;
- ;; DESCRIPTION:
- ; Read a random record in a file. The record number is taken from
- ; the random record field table.dskfcb.fcbrec and its length
- ; is determined from the table.dskfcb.lrs field. Data is read
- ; to the current disk transfer address.
- ;
- ;; RETURNS:
- ; 0 if successful, 1 if EOF on read, or if disk full on write and
- ; no data is written. 2 if there is insufficient space in the DTA
- ; segment to read or write the specified data, 3) if EOF on read
- ; and the record is a partial record;
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dosrdrrec,,dosrdrre
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr[bx],0ffh
- mov ah,21h ;dos random read function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return error code in AL
- cproce
-
- ;==>-- int doswtrrec(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE
- ;
- ;; DESCRIPTION:
- ; Functions exactly as dosrdrrec except writes instead of reads
- ;
- ;; RETURNS:
- ; 0=write successful, 1=diskette full, 2=DTA too small
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc doswtrrec,,doswtrre
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr[bx],0ffh
- mov ah,22h ;dos random write function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return error code in AL
- cproce
-
- ;==>-- int dosrdrblk(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE structure
- ;
- ;; DESCRIPTION:
- ; Dos random read block. Read one or more random records in a
- ; file. The record number of the first record to be read is taken
- ; from the random record field (table.dskfcb.fcbrec) and its
- ; length is specified by table.dskfcb.lrs on entry. The number
- ; of records to be read in this sequence at this position is
- ; specified by tbl.rbytes on entry. Data is read to the disk
- ; transfer address (DTA) (previously set). The file attribute
- ; must be specified in table.dskfcb.dskattr.fattr on entry
- ; and will be used.
- ;
- ;; RETURNS:
- ; 0=successful, 1=end of file, 2=insufficient space in DTA segment
- ; 3=If EOF ( a partial record was read and filled out with zeros)
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dosrdrblk,,dosrdrbl
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr[bx],0ffh
- mov cx,[bx+rbytes] ;Number of records to read
- mov ah,27h ;dos random write function
- int 21h
- if _LDATA
- pop ds
- endif
- mov [bx+abytes],cx ;save number of bytes read
- xor ah,ah ;return error code in AL
- cproce
-
- ;==>-- int doswtrblk(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE structure
- ;
- ;; DESCRIPTION:
- ; Dos random write block. Write one or more random records in a
- ; file. The record number of the first record to be written is taken
- ; from the random record field (table.dskfcb.fcbrec) and its
- ; length is specified by table.dskfcb.lrs on entry. The number
- ; of records to be written in this sequence at this position is
- ; specified by tbl.rbytes on entry. Data is written from the disk
- ; transfer address (DTA) (previously set). The file attribute
- ; must be specified in table.dskfcb.dskattr.fattr on entry
- ; and will be used.
- ;
- ;; RETURNS:
- ; 0=successful, 1=end of file, 2=insufficient space in DTA segment
- ; 3=If EOF ( a partial record was read and filled out with zeros)
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc doswtrblk,,doswtrbl
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr[bx],0ffh
- mov cx,[bx+rbytes] ;Number of records to read
- mov ah,28h ;dos random write function
- int 21h
- if _LDATA
- pop ds
- endif
- mov [bx+abytes],cx ;save number of bytes read
- xor ah,ah ;return error code in AL
- cproce
- endps
- end
-