home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / MISC.ZIP / CLONE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-21  |  1.4 KB  |  53 lines

  1. Program example;
  2.   {-demonstrate the CLONE process}
  3. Const
  4.   installed : Boolean = False;
  5.  
  6.   Procedure install;
  7.     {-set installation parameters for the program}
  8.  
  9.     Procedure clone;
  10.       {-write the memory resident image of the program to the disk}
  11.     Type
  12.       pathname = String[64];
  13.     Var
  14.       f : File;
  15.       fname : pathname;
  16.  
  17.       Function CodeSize : Integer;
  18.         {-return the exact size of this program's code in memory}
  19.       Var
  20.         i : Byte;
  21.       Begin
  22.         i := 11;
  23.         While Not((Mem[DSeg-2:i+3] <> $00E9) And (MemW[DSeg-2:i+4] = $0000)) And
  24.         Not((MemW[DSeg-2:i+0] = $00E9) And (MemW[DSeg-2:i+2] = $E800)) Do
  25.           i := i+1;
  26.         CodeSize := ((((DSeg-2)-CSeg) Shl 4)+i+6)-$100
  27.       End {CodeSize} ;
  28.  
  29.     Begin
  30.       Write('Enter filename where installed copy will be stored: ');
  31.       ReadLn(fname);
  32.       Assign(f, fname);
  33.       {should check for overwrite here}
  34.       Rewrite(f, 1);
  35.       BlockWrite(f, Mem[CSeg:$100], codesize);
  36.       {should check for errors here}
  37.       Close(f);
  38.     End {clone} ;
  39.  
  40.   Begin
  41.     {prompt for installation options}
  42.     {modify TYPED CONSTANTs to store the customized info in the code segment}
  43.     installed := True;
  44.     clone;
  45.     Halt;
  46.   End {install} ;
  47.  
  48. Begin
  49.   {call the installation procedure if not previously installed}
  50.   If Not(installed) Then install;
  51.   {normal statements}
  52. End.
  53.