Create or Truncate File





QuickBasic


' DOS 2+ - CREAT - CREATE OR TRUNCATE FILE

'$INCLUDE: 'qb.bi'

DIM filename AS STRING
DIM inregs  AS RegTypeX
DIM outregs AS RegTypeX

filename = "C:\INT\124.txt" + CHR$(0)

' File Attributes
inregs.CX = 32  ' Archive
' Bits:
'  0 read-only
'  1 hidden
'  2 system
'  3 volume label (ignored)
'  4 reserved, must be zero (directory)
'  5 archive
'  7 if set, file is shareable under Novell NetWare

inregs.DS = VARSEG(filename)
inregs.DX = SADD(filename)
inregs.AX = &H3C00

' DOS interrupt with sub-function &H3C

CALL InterruptX(&H21, inregs, outregs)

IF outregs.FLAGS AND 1 THEN
   PRINT "Error creating >> " + filename
   BEEP: END
END IF

PRINT "File Handle:"; outregs.AX