Assembly Language Help (alang.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.
CreateNew
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* 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:PBYTE
 
        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
        .IF     carry?
        mov     ax, -1                  ; Set error code
        .ENDIF
        ret
 
CreateNewFile ENDP
                                    -♦-