home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vp21beta.zip / OEXMPSRC.RAR / EA / TESTEA.PAS < prev   
Pascal/Delphi Source File  |  2000-08-15  |  2KB  |  91 lines

  1. {█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
  2. {█                                                       █}
  3. {█      Virtual Pascal Examples  Version 2.1             █}
  4. {█      Extended Attributes Example                      █}
  5. {█      ─────────────────────────────────────────────────█}
  6. {█      Copyright (C) 1996-2000 vpascal.com              █}
  7. {█      Written May 1996 by Allan Mertner                █}
  8. {█                                                       █}
  9. {▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}
  10.  
  11. {$Delphi+,T-,Use32-}
  12.  
  13. program TestEA;
  14.  
  15. uses
  16.   Os2EA, Os2Base, VPUtils, SysUtils;
  17.  
  18. procedure EATest( EAList: tEAList );
  19. var
  20.   i : integer;
  21.   l : record
  22.     EAType : SmallWord;
  23.     Data   : Longint;
  24.   end;
  25.  
  26. begin
  27.   with EAList do
  28.     try
  29.       Writeln( 'EAList created for ',FileName );
  30.       // Output list of EA's
  31.       Writeln( 'EA Count = ', Count, ' :' );
  32.       For i := 0 to Count-1 do
  33.         with Items[i] as tEA do
  34.           Writeln( '#',i:2,': ',GetString );
  35.  
  36.       // Add a .Longname EA
  37.       With AddAscii( '.Longname', 'VP/2 Long Name' ) do
  38.         begin
  39.           Writeln( 'Added Ascii EA, .LONGNAME' );
  40.           Writeln( ' StringValue  : ',StringValue );
  41.         end;
  42.  
  43.       // Add another ASCII EA
  44.       With AddZAsciiZ( 'VP EA', 'Another EA written by VP/2' ) do
  45.         begin
  46.           Writeln( 'Added Ascii EA, VP EA' );
  47.           Writeln( ' StringValue  : ',StringValue );
  48.           // Change the value
  49.           StringValue := 'Changed value';
  50.         end;
  51.  
  52.       // Add a binary EA
  53.       l.eaType := eat_binary;
  54.       l.Data := $12345678;
  55.       AddEA( 'Longint EA', Sizeof(l), @l );
  56.  
  57.       // Remove the "VP EA" again
  58.       RemoveNamedEA( 'VP EA' );
  59.  
  60.       // Remove the first EA in the list
  61.       If Count > 0 then
  62.         RemoveEA( tEA( Items[0] ) );
  63.  
  64.       // Update file's list of EAs. rc = 0 means success
  65.       Writeln( 'Write data; rc = ', WriteToFile );
  66.     finally
  67.       Destroy;
  68.     end;
  69. end;
  70.  
  71. var
  72.   MyEA : tEAList;
  73.  
  74. begin
  75.   If ParamCount = 0 then
  76.     begin
  77.       Writeln( 'Please specify dir/filename as parameter' );
  78.       Halt(1);
  79.     end;
  80.  
  81.   try
  82.     MyEA := tEAList.Create( ParamStr(1) );
  83.  
  84.     EATest( MyEA );
  85.   except
  86.     on E:Exception do
  87.       Writeln( 'Exception : ',E.Message );
  88.   end;
  89. end.
  90.  
  91.