home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / OOPTUT34.ZIP / OBJINIT.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-09  |  1KB  |  44 lines

  1. program object_initialization;
  2.  
  3. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  4. {  Program to illustrate the initialization of a record by the use of an }
  5. {  object as opposed to conventional methods.  R. Shaw    17.2.91        }
  6. {         OBJINIT.PAS  ->  OBJINIT.EXE                                   }
  7. {________________________________________________________________________}
  8.  
  9. uses Crt;
  10.  
  11. type
  12.    obj = object
  13.          i : integer;
  14.          r : real;
  15.          s : string[50];
  16.          procedure Init( int : integer; re : real; st : string);
  17.          end;
  18.  
  19. procedure Obj.Init( int : integer; re : real; st : string);
  20.  
  21. begin
  22.    begin
  23.       i := int;
  24.       r := re;
  25.       s := st;
  26.    end;
  27. end;          { of method Obj.Init }
  28.  
  29. var
  30.    ThisObj  : obj;
  31.  
  32. begin
  33.      ClrScr;
  34.      ThisObj.Init(1234, 9.876, 'This is the string entry for this object');
  35.      writeln( 'The integer value is ', ThisObj.i);
  36.      writeln( 'The real value is ', ThisObj.r);
  37.      writeln( 'The string is " ', ThisObj.s, '"');
  38.      writeln;
  39.      writeln;
  40.      write('Press any key to continue: ');
  41.      repeat until keypressed;
  42. end.
  43.  
  44.