vbdpss.hlp (Table of Contents; Topic list)
Article Q45423
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 BASIC's CALL INTERRUPT Can Get/Set File Attributes in MS-DOS - Q45423
 
 The program listed below demonstrates how to use BASIC's
 CALL INTERRUPT statement to get and set the attributes of files in
 MS-DOS.
 
 More Information:
 
 The program below uses MS-DOS Interrupt 21h with function 43h
 (67 decimal) to get or set file attributes.
 
 FILEATT.BAS
 -----------
 To try this example in VBDOS.EXE:
 
   1. From the File menu, choose New Project.
   2. Copy the code example to the Code window.
   3. Press F5 to run the program.
 
 ' To run this program in the environment, you must invoke the
 ' environment with the /L switch to load the default Quick library:
 '    VBDOS.EXE /L          for Visual Basic 1.0 for MS-DOS
 
 DECLARE SUB showattributes (status AS INTEGER)
 
 ' Use the following include file for Visual Basic 1.0 for MS-DOS:
 REM $INCLUDE: 'VBDOS.BI'
 CONST SETREADONLY = &H1
 CONST SETHIDDEN = &H2
 CONST SETSYSTEM = &H4
 CONST SETARCHIVE = &H32
 DIM inregs AS RegTypex, outregs AS RegTypex
 CLS
 INPUT "Enter File Name (with full pathname): "; filename$
 
 ' Add CHR$(0) to make an ASCIIZ (null-terminated) string:
 filename$ = filename$ + CHR$(0)
 
 inregs.ax = &H4300                    ' Get file attributes.
 inregs.dx = SADD(filename$)   ' Offset of ASCIIZ filename.
 inregs.ds = VARSEG(filename$) ' Segment of ASCIIZ filename.
 ' For BC.EXE and QBX.EXE from BASIC PDS 7.00/7.10, substitute the
 ' above line with the following line:
 '   inregs.ds = SSEG(filename$)
 
 CALL INTERRUPTX(&H21, inregs, outregs)
 showattributes outregs.cx
 
 ' Set hidden attribute.
 inregs.ax = &H4301                    ' Set file attributes.
 
 ' Mask off the volume labels directory and reserved bits.
 setstatus% = outregs.cx AND &H27
 
 setstatus% = setstatus% OR SETHIDDEN ' Set hidden attribute bit.
 inregs.cx = setstatus%
 CALL INTERRUPTX(&H21, inregs, outregs)
 showattributes outregs.cx
 
 SUB showattributes (status AS INTEGER)
   PRINT
   PRINT "File Attributes Set"
   PRINT "-------------------"
   IF status% AND SETREADONLY THEN PRINT "read-only"
   IF status% AND SETHIDDEN THEN PRINT "hidden"
   IF status% AND SETSYSTEM THEN PRINT "system"
   IF status% AND 8 THEN PRINT "volume label"
   IF status% AND 16 THEN PRINT "directory"
   IF status% AND SETARCHIVE THEN PRINT "archive"
 END SUB