home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / SWAGFILE / TEXTFILE.SWG < prev   
Text File  |  1993-05-30  |  25KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00012         TEXT FILE MANAGEMENT ROUTINES                                     1      05-28-9313:58ALL                      SWAG SUPPORT TEAM        FASTIO.PAS               IMPORT              10           GB>Could you Write a MCSEL ;-) wich gives us some hints For making Text i/oπ GB>_much_ faster ? I read that about the SetTextBuf although I never triedπ GB>it. What are other examples? Some little example-sources ?ππType BBTYP   = ^BIGBUF;π     BIGBUF  = Array[0..32767] of Char;ππVar BUFFin   : BBTYP;        { general-use large Text I/O buffer }πVar BUFFOUT  : BBTYP;π    F        : Text;π    S        : String;ππProcedure BBOPEN (Var F : Text; FN : String; OMODE : Char;π                  Var BP : BBTYP);πVar S : String;πbeginπ{$I-}π  Assign (F,FN); New (BP); SetTextBuf (F,BP^);π  Case UpCase(OMODE) ofπ    'R' : beginπ            Reset (F); S := 'Input'π          end;π    'W' : beginπ            ReWrite (F); S := 'Output'π          end;π    'A' : beginπ            Append (F); S := 'Extend'π          endπ    elseπ  end;π{$I+}π  if Ioresult <> 0 thenπ    beginπ      Dispose (BP); FATAL ('Cannot open '+FN+' For '+S+' - Terminating')π    endπend;  { BBOPEN }ππto use:ππ  BBOPEN (F,'myFile.txt',r,BUFFin);π  While not Eof (F) doπ    beginπ      readln (F,S);π      etc.π    end;π  Close (F); Dispose (BUFFin)π                                   2      05-28-9313:58ALL                      SWAG SUPPORT TEAM        HEXDUMP.PAS              IMPORT              90          {   In the following message is a Complete Program I just wroteπ(including 3 routines from TeeCee's hints) which solves a particularπproblem I was having, but also demonstrates some things I see queriedπhere.  So, there are a number of useful routines in it, as well as aπwhole Program which may help.π   This Program dumps a Dos File to Hex and (modified) BCD.  It isπpatterned after Vernon Buerg's LIST display (using Alt-H), which I findπuseful to look at binary Files.  The problem is (was) I couldn't PrtScπthe screens, due to numerous special Characters which often hung myπPrinter.  So, I wrote this Program to "dump" such Files to either theπPrinter or a Printer File.  It substitutes an underscore For mostπspecial Characters (you can change this, of course).π   note, too, that it demonstates the use of a C-like Character streamπi/o, which is a Variation of the "stream i/o" which is discussed here.πThis allows fast i/o of any Type of File, and could be modified toπprovide perFormant i/o For Text Files.π   A number of the internal routines are a bit clumsy, since I had toπ(107 min left), (H)elp, More? make them "generic" For this post, rather than make use of after-marketπlibraries that I use (TTT, in my Case).π   Enjoy!...π}ππProgram Hex_Dump;        { Dump a File in Hex and BCD   930107 }πUses Crt, Dos, Printer;π{$M 8192,0,8192}π   {  Public Domain, by Mike Copeland and Trevor Carlsen  1993 }πConst VERSION = '1.1';π      BSize   = 32768;                           { Buffer Size }π      ifLinE  = 4;                          { InFormation Line }π      PRLinE  = 24;                              { Prompt Line }π      ERLinE  = 25;                               { Error Line }π      DSLinE  = 22;                             { Display Line }π      PL      = 1;                          { partial line o/p }π      WL      = 2;                            { whole line o/p }π      B40     = '                                        ';πVar   CP      : Word;                      { Character Pointer }π      BLKNO   : Word;                                { Block # }π      L,N     : Word;π      RES     : Word;π      LONG    : LongInt;π      NCP     : LongInt;              { # Characters Processed }π      FSize   : LongInt;                  { Computed File Size }π      BV      : Byte;                  { generic Byte Variable }π      PRtoK   : Boolean;π      PFP     : Boolean;π      REGS    : Registers;π      PRTFile : String;π      F1      : String;π      MSTR,S1 : String;π      PFV1    : Text;π      F       : File;π      B       : Array[0..BSize-1] of Byte;π      CH      : Char;ππProcedure WPROM (S : String);             { generalized Prompt }πbeginπ  GotoXY (1,PRLinE); Write (S); ClrEol; GotoXY (Length(S)+1,PRLinE);πend;  { WPROM }ππProcedure CLEARBOT;                   { clear bottom of screen }πbeginπ  GotoXY (1,PRLinE); ClrEol; GotoXY (1,ERLinE); ClrEolπend;  { CLEARBOT }ππFunction GETYN : Char;               { get Single-key response }πVar CH : Char;πbeginπ  CH := UpCase(ReadKey); if CH = #0 then CH := ReadKey;π  CLEARBOT; GETYN := CH;πend;  { GETYN }ππProcedure PAUSE;              { Generalized Pause processing }πVar CH : Char;πbeginπ  WPROM ('Press any key to continue...'); CH := GETYNπend;  { PAUSE }ππProcedure ERRor1 (S : String);       { General Error process }πVar CH : Char;πbeginπ  GotoXY (1,ERLinE); Write (^G,S); ClrEol; PAUSEπend;  { ERRor1 }ππProcedure FATAL (S : String);      { Fatal error - Terminate }πbeginπ  ERRor1 (S); Haltπend;  { FATAL }ππFunction TEStoNLinE : Byte;      { Tests For Printer On Line }πVar  REGS : Registers;πbeginπ  With REGS doπ    beginπ      AH := 2; DX := 0;π      Intr($17, Dos.Registers(REGS));π      TEStoNLinE := AH;π    endπend;  { TEStoNLinE }ππFunction SYS_DATE : String;   { Format System Date as YY/MM/DD }πVar S1, S2, S3 : String[2];πbeginπ  REGS.AX := $2A00;                                 { Function }π  MsDos (Dos.Registers(REGS));             { fetch System Date }π  With REGS doπ    beginπ      Str((CX mod 100):2,S1); Str(Hi(DX):2,S2); Str(Lo(DX):2,S3);π    end;π  if S2[1] = ' ' then S2[1] := '0';           { fill in blanks }π  if S3[1] = ' ' then S3[1] := '0';π  SYS_DATE := S1+'/'+S2+'/'+S3πend;  { SYS_DATE }ππFunction SYS_TIME : String;               { Format System Time }πVar S1, S2, S3 : String[2];πbeginπ  REGS.AX := $2C00;                                 { Function }π  MsDos (Dos.Registers(REGS));             { fetch System Time }π  With REGS doπ    beginπ      Str(Hi(CX):2,S1); Str(Lo(CX):2,S2); Str(Hi(DX):2,S3);π    end;π  if S2[1] = ' ' then S2[1] := '0';           { fill in blanks }π  if S3[1] = ' ' then S3[1] := '0';π  if S1[1] = ' ' then S1[1] := '0';π  SYS_TIME := S1+':'+S2+':'+S3πend;  { SYS_TIME }ππFunction EXISTS ( FN : String): Boolean;  { test File existance }πVar F : SearchRec;πbeginπ  FindFirst (FN,AnyFile,F); EXISTS := DosError = 0πend;  { EXISTS }ππFunction UPPER (S : String) : String;πVar I : Integer;πbeginπ  For I := 1 to Length(S) doπ    S[I] := UpCase(S[I]);π  UPPER := S;πend;  { UPPER }ππProcedure SET_File (FN : String);      { File Output For PRinT }πbeginπ  PRTFile := FN; PFP := False; PRtoK := False;πend;  { SET_File }ππProcedure PRinT_inIT (S : String);  { Initialize Printer/File Output }πVar X,Y : Word;πbeginπ  PRtoK := TestOnLine = 144; PFP := False; X := WhereX; Y := WhereY;π  if PRtoK thenπ    beginπ      WPROM ('Printer is Online - do you wish Printer or File? (P/f) ');ππ      if GETYN = 'F' then SET_File (S)π      elseπ        beginπ          WPROM ('Please align Printer'); PAUSEπ        endπ    endπ  else SET_File (S);π  GotoXY (X,Y)                            { restore cursor }πend;  { PRinT_inIT }ππFunction OPENF (Var FV : Text; FN : String; MODE : Char) : Boolean;πVar FLAG  : Boolean;πbeginπ  FLAG := True;                             { set default }π  Assign (FV, FN);                        { allocate File }π  Case UpCase(MODE) of                        { open mode }π    'W' : begin                                  { output }π            {$I-} ReWrite (FV); {$I+}π          end;π    'R' : begin                                   { input }π            {$I-} Reset (FV); {$I+}π          end;π    'A' : begin                            { input/extend }π            {$I-} Append (FV); {$I+}π          end;π    elseπ  end; { of Case }π  if Ioresult <> 0 then          { test For error on OPEN }π    beginπ      FLAG := False;           { set Function result flag }π      ERRor1 ('*** Unable to OPEN '+FN);π    end;π  OPENF := FLAG                        { set return value }πend;  { OPENF }ππProcedure PRinT (inD : Integer; X : String); { Print Report Line }πVar AF : Char;                              { Append Flag }π    XX,Y : Word;πbeginπ  if PRtoK then                         { Printer online? }π    beginπ      Case inD of              { what Type of print line? }π        PL  : Write (LST, X);              { partial line }π        WL  : Writeln (LST, X);              { whole line }π      endπ    end  { Printer o/p }π  else                                     { use o/p File }π    beginπ      XX := WhereX; Y := WhereY;π      if not PFP then                   { File not opened }π        beginπ          AF := 'W';                            { default }π          if EXISTS (PRTFile) thenπ            beginπ              WPROM ('** Print File '+PRTFile+' exists - Append to it? (Y/n) ');π              if GETYN <> 'N' then AF := 'A';π            end;π          if OPENF (PFV1, PRTFile, AF) then PFP := True { set flag }π          else FATAL ('*** Cannot Open Printer O/P File - Terminating');ππ        end;  { of if }π      GotoXY (XX,Y);                      { restore cursor }π      Case inD ofπ        PL  : Write (PFV1, X);                   { partial }π        WL  : Writeln (PFV1, X);                   { whole }π      end;π    end;  { else }πend;  { PRinT }ππFunction FSI (N : LongInt; W : Byte) : String; { LongInt->String }πVar S : String;πbeginπ  if W > 0 then Str (N:W,S)π  else          Str (N,S);π  FSI := S;πend;  { FSI }ππProcedure CLOSEF (Var FYL : Text);  { Close a File - open or not }πbeginπ{$I-} Close (FYL); {$I+} if Ioresult <> 0 then;πend;  { CLOSEF }ππFunction CENTER (S : String; N : Byte): String;  { center N Char line }πbeginπ  CENTER := Copy(B40+B40,1,(N-Length(S)) Shr 1)+Sπend;  { CENTER }ππProcedure SSL;                              { System Status Line }π{  This routine is just For "flash"; it can be omitted... }πConst DLM = #32#179#32;πbeginπ  GotoXY (1,1); Write (F1+DLM+'Fsz: '+FSI(FSize,1)+DLM+π                             'Blk: '+FSI(BLKNO,1)+DLM+π                             'C# '+FSI(CP,1));πend;  { SSL }ππ           {  The following 3 routines are by Trevor Carlsen }πFunction Byte2Hex(numb : Byte): String; { Byte to hex String }πConst HexChars : Array[0..15] of Char = '0123456789ABCDEF';πbeginπ  Byte2Hex[0] := #2; Byte2Hex[1] := HexChars[numb shr 4];π  Byte2Hex[2] := HexChars[numb and 15];πend; { Byte2Hex }ππFunction Numb2Hex(numb: Word): String;  { Word to hex String.}πbeginπ  Numb2Hex := Byte2Hex(hi(numb))+Byte2Hex(lo(numb));πend; { Numb2Hex }ππFunction Long2Hex(L: LongInt): String; { LongInt to hex String }πbeginπ  Long2Hex := Numb2Hex(L shr 16) + Numb2Hex(L);πend; { Long2Hex }ππFunction GET_Byte: Byte;         { fetch Byte from buffer data }πbeginπ  GET_Byte := Byte(B[CP]); Inc (CP); Inc (NCP)πend;  { GET_Byte }ππFunction EOS (Var FV : File): Boolean; { Eof on String File Function }πbeginπ  if CP >= RES then                    { data still in buffer? }π    if NCP < FSize thenπ      begin                               { no - get new block }π        BLKNO := (NCP div BSize);π        FillChar(B,BSize,#0);                  { block to read }π        Seek (F,BLKNO*BSize); BlockRead (F,B,BSize,RES); CP := 0;π      endπ    else RES := 0;π  EOS := RES = 0;πend;  { EOS }ππbeginπ  ClrScr; GotoXY (1,2);π  Write (CENTER('--- Hex Dump - Version '+VERSION+' ---',80));π  if ParamCount > 0 then F1 := ParamStr(1)π  elseπ    beginπ      WPROM ('Filename to be dumped: '); readln (F1); CLEARBOTπ    end;π  if not EXISTS (F1) then FATAL ('*** '+F1+' File not present - Terminating! ***');π  PRinT_inIT ('HEXDUMP.TXT'); F1 := UPPER(F1);π  PRinT (WL,CENTER('Hex Dump of '+F1+'  '+SYS_DATE+' '+SYS_TIME,80));π  Assign (F,F1); GotoXY (1,ifLinE); Write ('Processing ',F1);π  Reset (F,1); FSize := FileSize(F); CP := BSize; NCP := 0; RES :=πBSize;π  PRinT (WL,'offset  Addr  1  2  3  4  5  6  7  8  9 10  A  B  C  D  E  F  1234567890abcdef');π  While not EOS (F) doπ    beginπ      if (NCP mod 16) = 0 thenπ        beginπ          if NCP > 0 thenπ            beginπ              PRinT (WL,MSTR+S1); SSLπ            end;π          MSTR := FSI(NCP,6)+'  '+Numb2Hex(NCP); { offset & Address }π          S1 := '  ';π        end;π      BV := GET_Byte;                 { fetch next Byte from buffer }π      MSTR := MSTR+' '+Byte2Hex(BV);                     { Hex info }π      if BV in [32..126] then S1 := S1+Chr(BV)           { BCD info }π      else                    S1 := S1+'_';π    end;π  Close (F);π  While (NCP mod 16) > 0 doπ    beginπ      MSTR := MSTR+'   '; Inc (NCP);           { fill out last line }π    end;π  PRinT (WL,MSTR+S1); SSL; MSTR := 'Printer';π  if PFP thenπ    beginπ      CLOSEF (PFV1); MSTR := PRTFileπ    end;π  GotoXY (1,ifLinE+1); Write ('Formatted output is on ',MSTR);π  GotoXY (1,ERLinE); Write (CENTER('Finis...',80))πend.π  3      05-28-9313:58ALL                      SWAG SUPPORT TEAM        LINE-CNT.PAS             IMPORT              20          {π>I'm wondering if anyone can post me a source For another way toπ>find out the max lines in a Text File.π}ππ {.$DEFinE DebugMode}ππ {$ifDEF DebugMode}ππ   {$A+,B-,D+,E-,F-,G+,I+,L+,N-,O-,P-,Q+,R+,S+,T+,V+,X-}ππ {$else}ππ   {$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X-}ππ {$endif}ππ {$M 1024,0,0}ππProgram LineCounter;ππConstπ  co_LineFeed = 10;ππTypeπ  byar_60K = Array[1..61440] of Byte;ππVarπ  wo_Index,π  wo_BytesRead : Word;ππ  lo_FileSize,π  lo_BytesProc,π  lo_LineCount : LongInt;ππ  fi_Temp      : File;ππ  byar_Buffer  : byar_60K;ππbeginπ              (* Attempt to open TEST.doC File.                       *)π  assign(fi_Temp, 'linecnt.pas');π  {$I-}π  reset(fi_Temp, 1);π  {$I+}ππ              (* Check if attempt was sucessful.                      *)π  if (ioresult <> 0) thenπ    beginπ      Writeln('ERRor opening TEST.doC File');π      haltπ    end;ππ              (* Record the size in Bytes of TEST.doC .               *)π  lo_FileSize := Filesize(fi_Temp);ππ              (* Initialize Variables.                                *)π  lo_LineCount := 0;π  lo_BytesProc := 0;ππ              (* Repeat Until entire File has been processed.         *)π  Repeatπ              (* Read in all or a 60K chunk of TEST.doC into the      *)π              (* "buffer" For processing.                             *)π    blockread(fi_Temp, byar_Buffer, sizeof(byar_60K), wo_BytesRead);ππ              (* Count the number of line-feed Characters in the      *)π              (* "buffer".                                            *)π    For wo_Index := 1 to wo_BytesRead doπ      if (byar_Buffer[wo_Index] = co_LineFeed) thenπ        inc(lo_LineCount);ππ              (* Record the number of line-feeds found in the buffer. *)π    inc(lo_BytesProc, wo_BytesRead)ππ  Until (lo_BytesProc = lo_FileSize);ππ              (* Close the TEST.doC File.                             *)π  close(fi_Temp);ππ              (* Display the results.                                 *)π  Writeln(' total number of lines in LinECNT.PAS = ', lo_LineCount)ππend.π{π  ...to find a specific line, you'll have to process the Text File upπ  to the line you are after, then use a "seek" so that you can readπ  in just this line into a String Variable. (You'll have to determineπ  the length of the String, and then set the String's length-Byte.)π}                                                                                                 4      05-28-9313:58ALL                      SWAG SUPPORT TEAM        LISTER.PAS               IMPORT              63          {     Right now I'm writing an interpreter For a language that Iπdeveloped, called "Isaac".  (It's Physics oriented).  I'd be veryπinterested in you publishing this inFormation regarding PascalπCompilers, though I would likely not have time to do the excercisesπright away.ππ   Ok, Gavin. I'll post the lister (not Really anything exceptional,π   but it'll get this thing going in Case anyone joins in late.)ππ   Here's the lister Program:π}π{$I-}πProgram Lister;ππUses Dos;ππ{$I PTypeS.inC}π{Loacted in the SOURCE\MISC Directory.}ππFunction LeadingZero(w:Word): String;{convert Word to String With 0's}π   Var s :String;π   beginπ      Str(w:0,s);π      if Length(s) < 2 then s := '0'+s;π      LeadingZero := s;π      if Length(s) > 2 then Delete(s,1,Length(s)-2);π   end;πππFunction FormatDate :String; { get system date and pretty it up }π   Constπ      months : Array[1..12] of String[9] =π      ('January', 'February', 'March', 'April', 'May', 'June', 'July',π       'August', 'September', 'October', 'November', 'December');π   Var s1,fn : String; y,m,d,dow : Word;π   beginπ      GetDate(y,m,d,dow);π      s1 := leadingZero(y);π      fn := LeadingZero(d);π      s1 := fn+' '+s1;π      fn := months[m];π      s1 := fn+' '+s1;π      FormatDate := s1;π   end;ππFunction FormatTime :String; { get system time and pretty it up }π   Var s1, fn : String; h,m,s,s100 : Word;π   beginπ      GetTime(h,m,s,s100);π      fn := LeadingZero(h);π      s1 := fn+':';π      fn := LeadingZero(m);π      FormatTime := s1+fn;π   end;ππProcedure Init(name:String);π   Var t,d        :String;π   beginπ      line_num := 0; page_num := 0; level := 0;π      line_count := MAX_LinES_PER_PAGE;π      source_name := name;π      Assign(F1, name);      { open sourceFile - terminate if error }π      Reset(F1);π      if Ioresult>0 thenπ      beginπ         Writeln('File error!');π         Halt(1);π      end;π      { set date/time String }π      d := FormatDate;π      t := FormatTime;π      date := d+'  '+t;π   end;ππProcedure Print_Header;π   Var s, s1 :String;π   beginπ      Writeln(F_FEED);π      Inc(page_num);π      Str(page_num, s1);π      s := 'Page '+s1+'   '+source_name+'  '+date;π      Writeln(s     Date'     := 'Pag   '+n rein. I'll itionπ        te;πiteln(s       De'     := 'Pag   '+n reil. I'll itionπ   eHexChae Ps       Dbeginπ  rma;π   'Pag   '+n l+n rFthe listd,s *)π  {lae Phae     Db   Dπ  rma;π   'Pag   '+Pag n rFPag Pag   '+P)π  lse T onl0)         { tFthe llDb   e   Dma;π   'lt <e;π    2 thene ineln(l0) lse     ere the llDb   e   Dma;π   'lt <ere t8 2 t π    ls2b2Hex(LS  { Fileimeπ   llDb   e   Dle lloleimeπ c43meπ   lpde ls2a;π       { Fileimeπ   llDb   e   Dle llog Paeπ cze; e   lT{lae Phaontai llog _tS Initial   e   e   Dle lloglle l)π 2,l5-28-9313 e.aont Paeterminnateitial   e   e   Dle  llolle l   5,l5-28-9313ge_nf ls2a;π  t,ropo  e nnateit   el     e   Dle l  t <ele lloT rexTπ    2a;πt Paeopo  e nnateit   el     e   Dlcze; t <    4loT Taring;π ,8 aonnata;πt Pa nnapo  nnateit  e   teits othe aPa nnSProcedure PriaonnSDa;πt Pa nnapo  nnateit  e   teitsinπ e aP,πriteln(ilei othe  2  '+dateolle l ateit  e         beg t <the aP,πritel tei.30l:8,t := FeIteolteiteateiD  e         beg t <t    P,πritellpdel,πri    e    Solean;πVme+nate  e         llle .30n   en }π olpde    r    SEF  Solean;πVme+nate  ee        :=   .30e   teitseadintS           ateoolean;πVme+nl    .30re ls2:uts o30e e+nastseal   S           ateooleaoleame+n    utin   .nastsetstseal   0l:ete(s,1,Lecolea       oole  atoleaoleautin teit  oole  I-  atoleaoleautin T    a      loole', loleaoleautin teit  o{ daolea    .30reeaut,1,Lee0  '+oleaoleautieeπsampling ra;eautin lleauteautiit  o{ de2He.e }ππbeginπ  ClrScr;π  TeFileer of linin lleautelea  t  o{ de2He.e }ππbeginπ  ClrScr;πglleFilering; lintin le0eo.t{ de2He.e,s sonπ  de2He.einπ ππbenπ  ClrSFilerr Fi"d,π-at version number as  son0eo.e2He.einπ  πbenπ  ClrSFilerr Fi"d,π-at versio PaeDπ-ation F{ daole  { FilSs  bLerr  πbenπ lerrlrSFerr Fi"drsio Vme+ndHex Dump - Version:n(F_FEED)Cl  πbs  seerrlrSFerr Fi"drsio Vme+ndHexn F{p - i"d, o  n nnas2b2Hex(NS IntegeraPaπ-atr Fi"drsio Vlerr  stπ  co_Linearh2n,/nnasexn 6x(NSring;geraPaπ-atr Fi"drsiome+nrr  i"drgco_LieerrOt,eπBoring,/nnaseS In 6x(ring;ger Fi"dautied  { OPENF }ππProcec nnasD= UPPER(Fnasellletelnring;ger Fi"dautied HexnPENFo_Lilean; { O  '+so := FeIteolteiteatFFOUT  : BBTY;ennasD=ler Fie Fi"ied Hexn'Pro Hex(N2,Todrgco_LishinFOUT nnaBBTY;ome+sD=ler Fie Fi"ied Hed Hero Her F ,todrg(NSringe      eNCP); Sπ  else    F }π Fi"ied Hed lied et the ScSodrr.  Ie    SrinoP);  l  else    F }π Fi"ie}π Fd li}π Fn;4ied o14PENeen Pri in the ed Hedl   Sre Sri;  l  elze t2he period of the wild car_Byte;,todrg(NSri'  Sr PriD;  l    ze t2he period of the wil wil.]Byte(    n,   o;  l(NSri' i;  r Pr;  l    perio"drsd0 thenπ        begon SS,   o;  l,2Sri'1i;  r Pr;  l    perio"drsd0 thenπ Hed ,  be    { dS   Theserio"drl   o;e o; Sri'1i; ault4   ze t2heTe t2sue t2he{ dS  { seserdS  rl   o;e o; Sri'1i; ault4   ze t2h'+so o Vm   PRmeEtelea  ,ee) th)lS  { e { sdS  rl  9 10 PRmeC2rr. NCna  Vm ze t   o; so o,ee) th)lS  { e { sdS  rl  9 10 PPPPP end;π4   e use--e o; Sc)lS  o; so h)lSee) )lS  { erl  9P); dile }π    beginπ  f Lne4; Sc PPP       h)lSee) )lS  { erl  9P); dile }π  --e 'l  bedaole  rl  9e2Hex(Bf_tS whole }nna rl rl  9P); dillS  {wr new block }π     t    ex(Bf_tS whoUntinna Il rl  9P); dillS  {willSw blillSm o newBBTY;eeress }4  rl  9 ai llog _tc{will  9P); {wrillS{willSw o new  { ed to hex String.}πb0(p.; _tc{wil6  9Pero(wrillS{willSw o new SWAGd toId led tls(ts.  s0  { sEach blew  { l_tc{wec{wi9Pero(wr    Ter is exactly $1A Bytes l oole  IStri  { l_tc,1,Lee{ l_ro(wr    Ter is exactly $1A Bytes  $1A2heT(rina Il rlS  {l_ro(wπrittSginπ  CE t2ex Sactly $1A Bylexac, *)π  Wri7D);π      Inc(    n,   o;   CE l_ro Sactlly $A Bylexac, *)π  Wri7D);πl    ac, E ec(  ttllpdeltSπ{  Thisrio1A B1A Bylexac, l SacllDb 40D140D140Dnnec(  ttl1edeltam LiThisrio1A B1A Bylexae, l , l '8l l Sth)lS  {hisrio1A  Sr Prilse    F }πD);π  c , l B1A Byl Saxae, , l '8lS  {heoolOPENF }π $1A2heT(rina 'II lo_Bytesse  Hyl Saxae, , l '8lS  {heoolOPENF }{ e A2he Hyl SV}π $)({hedile }π Fi"drs_tSutines ao onec(oolOPENF }{ l{ e *)π  Wri7D);π4  IMPORTSutines aelutinina l onee(oolOPENF }{ l{ e *)π  Wli7D)*)π  )lS  {{ e π    e π FbLolOPtinina oolOoneeolOPENF *)π    : W"I;O;  *)π    e πPORTI π FeLolOPtinina oolOoneeolOPlNF *PENF   oneet      ogitizedlOoneel)π   e    ORTI π Fing will  90r,e LinE); Wr,      ogiti+'/'aeluel)π   e    ORTI π F π FwillORTIg the sameLol  Wri7DaPENr; bLe   +'/'ael e  l)π e    ORTFwill4  I to do ths2aheπspeclaPENORTIIe      (ael e  l)π e    ORTFeill4RTFw,erdo t5F *)π  e  l)π FilSs  bLec)π e      (l)π l e )π e    4RTFwS  r=2 e A] String;  {eilSsRTFw1c)π e      (l)π l e )π e    4TFw,S  raPENπ e  TFwS   (l)π l  (l)π l 9 1bL )π e      e )π)π l )π e    raPEogitid'HEXDUMP.TXT'); F1lOoneeolOPlNF *PENF   oneet      oN  raPEogiti 'HEXDUMP.TXT'); F1lOoneeolOPlNF *PE LiThineet      oN  raPEogl , 'HEX{{ e πXT'); F1lOPlm     oN(,- So    *PE LiT    neet    oN  , 'HE_Lineme}π   e πP{ e π    el(,- - SoI *PEπLiT    neet    oN  , 'HElLine neem: e π1.e0AUSEπ        endπ ; bual same}π   lPEπLieπLiTneet    _Byt0lowed by three Bytes spec8, spexeeme}ππ   πEπLiππLiTneet    _Byt0lowed bl thrwed ASl by pexeemesnPE LiTh0lowed blFi"ie}π Fdc bl t    _Bd by0low bl thrwy pexT nna if a 'Se HexH blFeeme π Fd1 bl t    _Bd by0low bl thrwy pexT me πign (F,F1); GotomN  c ,Bytes cy0lo1 bl t by0l _Bdy0low blexT moN  LeadingZeFwS  π    eniBytes cyN    c 't by0l _Bdy0low blex0l _N  Leadiπ,LieπLiTnF1); Bytedy0low, endπ tSresent -lORwy p blex0l _N  lytesAr+' File not presen0a.F }π Fi tSry pet -l tei p blex0l _N  lytesApecitesA3a{t pr3tRTFw,e0es2esπrighSS_TIME,8TFwlexTlex0l _N  lyl); BArf (NCP mod 16) = 09(F1);y0lowhSS_,SME,8liniexTlex0l _N  lyl); Bthis); Bel e  l) = 0erdo wedthere acS al 8 bi(NCP mlSME,8eE,8lxTlex0l    *tesA3a{te acS ';ytes spec8, spexeeme}ππ   π,ME,8)π eINCP e0l    *tesA3a{te acS ';yles s*tesfle8, s0 l )π3a{te t, TF.ecS ';yl,ME,8eE,8)NCP e0l     aha2πign ts the, s0 l )πa{teπ3a{TF.ecS ';F1);E,8eE,8)NCP e0l         πignaha2nl    a2πia{TF.einiexTlex {wrilt,;  o    E,8eE,8l   CP e        2nl   Reca2 oins in latS_TIMEpretera{TF a langua wed CP e        2nl   R)π3a oin+nl ππLiTnyl Saxe)te  latS_TIit up }St Byte fc8, thenl   R)π3a ol oinad_Byte;             acS al 8 bQSt Byte fcwy peenl I R)π3a ol oinad_Bytenad_    nad_i+acSE  = 0e5S al 8 b:String R)π3a ol info }πlFeS_TIte; d_    nal_   ,4"cBytnlangua w5:Str 0e5eptional,π  FwS  FeS_TIte; d_    nal_ c '4"cB   S[lol oangua wed2nl   R,ngZeroS; Inc (NniB    _    nal_ c l  naadthe size in Bytes 2tuteengZengZe1Inc sizeB    _    nal_ c l   l  the naadl_ c '4"cB etes 2   acfF DebugMo yte = 1e in BlzeB  eB     nal_ c[wo_ro :=  }St ByebGx3DF Dethe,o yt l= 1e in BlzeB  eB   B  el_ c[wo_.lex0l _N  lyl)0l  ptis cyN  1buabL  eB l= 1e B  e Blz  eB   Bwo_.lE : "Ibf,ia(c0l  ptishcyN  1buabL  eB l= 1e B  e  B   eB c[wo e  Blz taa(c0l  seAH;π    endπe;eeB   BlhcyN eyN  bL  eB lST.dR4"c eB l= 1e Hoinad_Bl;π  lz tIπe;eeB   BlhcyN eyN  bL  eB lST.dR4lex0B l=PENFoleB lOPlNFe'     2n,   oN  beeB   ByN  cyN N  bL  e4lex0f (N"cccccccccccc      s1 := Te oN  oN {   BπN  cyN N  bL  e4lex0f (Nlcccc bL +Epr{   BπN  c[w     e4lex0fl  Wri7DaPcx0f cyN N  ex0f  e4x0f (NlcEpr{      "cimFile Frwed Afl        e4l0f cyN N  ex0f  e4x00f  lcEp0f  4 SSL; ,S   enieoBoolea_tS of Byte   e4leN  ex0f  e4xlπN  π  Tp  beg 4 SSL; ,S   enieoBoolS of(Nlcl   eIleN  ex0f  e4xlπN  π4xlπ  be4xlπ(1ST.doC x0f  e4 o-  πigxlπ  b_tSfer  : bFi"e4xlπN    e4IByteeadin1ST.doC lπ  b_t o-