qa.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CreateNewFile
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* CreateNewFile - Creates a new file with specified attribute. Differs
;* from the CreateFile procedure in that it returns an error if file
;* already exists. For DOS versions 3.0 and higher.
;*
;* Shows:   DOS Function - 5Bh (Create New File)
;*
;* Params:  attr - Attribute code (see header comments for CreateFile)
;*          fspec - Pointer to ASCIIZ file specification
;*
;* Return:  Short integer with file handle or -1 for error
 
CreateNewFile PROC \
        USES ds, \
        attr:WORD, fspec:PTR BYTE
 
        LoadPtr ds, dx, fspec           ; Point DS:DX to file spec
        mov     cx, attr                ; CX = attribute
        mov     ah, 5Bh                 ; AH = function number
        int     21h                     ; Create New File
        jnc     exit                    ; Return AX = handle if ok
        mov     ax, -1                  ; Else set error code
exit:   ret
 
CreateNewFile ENDP
                                    -♦-