home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l170 / 3.ddi / SOURCE / HIDE.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-09-22  |  1.5 KB  |  60 lines

  1. ' HIDE.BAS
  2. '
  3. ' Changes file attribute bytes to hide or unhide a file's
  4. ' directory entry.
  5. '
  6. DECLARE SUB TestError (AXReg%, flags%)
  7. ' $INCLUDE: 'QB.BI'
  8.  
  9. DEFINT A-Z
  10. DIM InRegs AS RegType, OutRegs AS RegType
  11.  
  12. ' Get the file name and what to do.
  13. CLS
  14. PRINT "Hidden File Program": PRINT
  15. INPUT "Enter file name: ", FileName$
  16. DO
  17.    INPUT "Hide or unhide (H or U): ", Action$
  18.    Action$ = UCASE$(Action$)
  19. LOOP WHILE Action$ <> "H" AND Action$ <> "U"
  20.  
  21. ' Make the file name an ASCIIZ string for DOS.
  22. FileName$ = FileName$ + CHR$(0)
  23.  
  24. ' Get the current file attribute.
  25. ' Current attribute comes back in OutRegs.AX
  26. InRegs.ax = &H4300
  27. InRegs.dx = SADD(FileName$)
  28. CALL INTERRUPT(&H21, InRegs, OutRegs)
  29. CALL TestError(OutRegs.ax, OutRegs.flags)
  30.  
  31. ' Change the hidden attribute bit in the old attribute byte value.
  32. IF Action$ = "U" THEN
  33.    InRegs.cx = OutRegs.cx AND &HFD
  34. ELSE
  35.    InRegs.cx = OutRegs.cx OR &H2
  36. END IF
  37. ' Set AX to indicate the Change Atribute DOS function.
  38. InRegs.ax = &H4301
  39. CALL INTERRUPT(&H21, InRegs, OutRegs)
  40. CALL TestError(OutRegs.ax, OutRegs.flags)
  41.  
  42. END
  43. ' If carry flag set, print error message and end program.
  44. SUB TestError (AXReg, flags) STATIC
  45.    IF (&H1 AND flags) <> 0 THEN
  46.       ' Get the error number out of AX.
  47.       SELECT CASE AXReg AND &HF
  48.          CASE 2
  49.             PRINT "File not found."
  50.          CASE 3
  51.             PRINT "Path not found."
  52.          CASE 5
  53.             PRINT "Access denied."
  54.          CASE ELSE
  55.             PRINT "Unrecognized error."
  56.       END SELECT
  57.       END
  58.    END IF
  59. END SUB
  60.