home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / MISCTI10.ZIP / TI310.ASC < prev    next >
Encoding:
Text File  |  1988-04-18  |  1.8 KB  |  72 lines

  1. PRODUCT : TURBO PASCAL     NUMBER : 310
  2. VERSION : 3.0xx
  3.      OS : PC-DOS, MS-DOS
  4.    DATE : June 19, 1986
  5.  
  6.   TITLE : FILE ATTRIBUTES, SETTING & GETTING
  7.  
  8. Use  the  following routines to set and get a  particular  file's 
  9. attribute from within a Turbo Pascal program. 
  10.  
  11. type
  12.   AnyString = string[80];                { Generic string type }
  13.   Registers = record
  14.     case Byte of
  15.       1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: integer);
  16.       2 : (AL, AH, BL, BH, CL, CH, DL, DH: byte);
  17.   end;
  18.  
  19. function SetFileAttribute(FileName : AnyString;
  20.                          Attribute : integer) : integer;
  21. { Sets a particular file's attribute byte - returns error code:
  22.  
  23.   0 - no error
  24.   2 - file not found
  25.   3 - path not found
  26.   5 - access denied
  27.  
  28. }
  29. var Reg : Registers;
  30. begin
  31.   Reg.AH := $43;
  32.   Reg.AL := $01;
  33.   Reg.CX := Attribute;
  34.   FileName := FileName + #0; { Make the file name an ASCIIZ
  35. string }
  36.   Reg.DS := Seg(FileName);
  37.   Reg.DX := Succ(Ofs(FileName));
  38.                         { The offset of the first char in the
  39. name }
  40.   MsDos(Reg);
  41.   if not (Reg.AX in [2, 3, 5]) then
  42.     Reg.AX := 0;
  43.   SetFileAttribute := Reg.AX;
  44. end; { SetFileAttribute }
  45.  
  46. function GetFileAttribute(FileName : AnyString;
  47.                      var Attribute : integer) : integer;
  48. { Gets a particular file's attribute byte - returns error code:
  49.  
  50.   0 - no error
  51.   2 - file not found
  52.   3 - path not found
  53.   5 - access denied
  54.  
  55. }
  56. var Reg : Registers;
  57. begin
  58.   Reg.AH := $43;
  59.   Reg.AL := $00;
  60.   FileName := FileName + #0; { Make the file name an ASCIIZ
  61. string }
  62.   Reg.DS := Seg(FileName);
  63.   Reg.DX := Succ(Ofs(FileName));
  64.                         { The offset of the first char in the
  65. name }
  66.   MsDos(Reg);
  67.   Attribute := Reg.CX;
  68.   if not (Reg.AX in [2, 3, 5]) then
  69.     Reg.AX := 0;
  70.   GetFileAttribute := Reg.AX;
  71. end; { GetFileAttribute }
  72.