{@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
The purchaser of these procedures and functions may include them in COMPILED
programs freely, but may not sell or give away the source text.
}
{$I regpack.typ}
{$I filename.typ}
{$I fileattr.lib}
{$I errmessg.lib}

type
  AttString = string[6];
  CharSet   = set of char;
const
  AttChars : charset = ['R','H','S','V','D','A'];

var
  this_file : filename_type;
  error, N,
  this_attribute : byte;
  char_attributes : AttString;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
function convert(attribute:byte):AttString;
var
  temp : attString;
begin
  temp := '      ';
  if attribute and 1 = 1 then temp[1] := 'R';
  if attribute and 2 = 2 then temp[2] := 'H';
  if attribute and 4 = 4 then temp[3] := 'S';
  if attribute and 8 = 8 then temp[4] := 'V';
  if attribute and 16 = 16 then temp[5] := 'D';
  if attribute and 32 = 32 then temp[6] := 'A';
  convert := temp;
end;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
function UnConvert(atts : attString):byte;
var
  temp : byte;
begin
  temp := 0;
  if pos('R',atts) <> 0 then temp := temp + 1;
  if pos('H',atts) <> 0 then temp := temp + 2;
  if pos('S',atts) <> 0 then temp := temp + 4;
  if pos('V',atts) <> 0 then temp := temp + 8;
  if pos('D',atts) <> 0 then temp := temp + 16;
  if pos('A',atts) <> 0 then temp := temp + 32;
  UnConvert := temp;
end;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
begin
  WriteLn('Enter the name and full path of file to be changed.');
  ReadLn(this_file);
  FileAttribute('R',this_file,this_attribute,error);
  if error = 0 then
    begin
      WriteLn('Current attributes are ',Convert(this_attribute));
      WriteLn('Enter new attributes--[R]ead only, [H]idden, [S]ystem,[A]rchive');
      read(char_attributes);
      for N := 1 to length(char_attributes) do
         char_attributes[N] := UpCase(char_attributes[N]);
      this_attribute := UnConvert(char_attributes);
      FileAttribute('W',this_file,this_attribute,error);
      if error = 0 then
        begin
          WRite('Sucessfully changed the attribute of ',this_file);
          WriteLn(' to ',convert(this_attribute),'.');
        end
      else WriteLn(message(error));
    end
  else WriteLn(message(error));
end.
