home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sibyl_cw.zip / Filter.PAS < prev   
Pascal/Delphi Source File  |  1998-02-14  |  1KB  |  49 lines

  1. PROGRAM FilterMe;
  2.  
  3. (*                                                                      *)
  4. (* Program to filter a single dialog compiled into a resource (.RES)    *)
  5. (* and convert it into a SP/2 or Sibyl 'byte' array that could be passed*)
  6. (* to the WinCreateDlg function.                                        *)
  7. (* Compile in text mode.                                                *)
  8. (*                                                                      *)
  9.  
  10.  USES SysUtils;
  11.  
  12.  VAR F    : FILE OF BYTE;
  13.      FF   : TEXT;
  14.      S    : STRING[100];
  15.      B    : BYTE;
  16.      I, J : LONGINT;
  17.  
  18. BEGIN
  19.  IF ParamStr(1) = '' THEN Halt;
  20.  S := ParamStr(1);
  21.  Assign(F,S);
  22.  {$I-} Reset(F); {$I+}
  23.  IF IOResult <> 0 THEN Halt;
  24.  S := Copy(S,1,Length(S)-4) + '.TXT'; {output is samename.txt}
  25.  Assign(FF,S);
  26.  {$I-} Rewrite(FF); {$I+}
  27.  IF IOResult <> 0 THEN Halt;
  28.  I := 0; J := 0;
  29.  Writeln(FF,'('); {const byte array = '($xx,$xx,...,$xx)'}
  30.  WHILE NOT(EOF(F)) DO
  31.   BEGIN {read file until end}
  32.    Read(F,B); Inc(I);
  33.    IF I > 12
  34.     THEN BEGIN {bypass identifiers and dialog size info}
  35.           IF J <> 0 THEN Write(FF,',');
  36.           Write(FF,'$',IntToHex(B,2)); Inc(J);
  37.           IF J = 16
  38.            THEN BEGIN {16 bytes per line}
  39.                  J := 0;
  40.                  IF NOT(EOF(FF)) THEN Writeln(FF,',');
  41.                 END; {then}
  42.          END; {then}
  43.   END; {while}
  44.  Write(FF,')');
  45.  Close(F);
  46.  Close(FF);
  47. END.
  48.  
  49.