objpas.pp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998,99 by the Free Pascal development team
  5. This unit makes Free Pascal as much as possible Delphi compatible
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$Mode ObjFpc}
  13. {$I-,S-}
  14. unit objpas;
  15. interface
  16. type
  17. { first, in object pascal, the types must be redefined }
  18. smallint = system.integer;
  19. integer = system.longint;
  20. { the compiler searches in the objpas unit for the tvarrec symbol }
  21. TVarRec = System.TVarRec;
  22. PVarRec = ^TVarRec;
  23. {****************************************************************************
  24. Compatibility routines.
  25. ****************************************************************************}
  26. { Untyped file support }
  27. Procedure AssignFile(Var f:File;const Name:string);
  28. Procedure AssignFile(Var f:File;p:pchar);
  29. Procedure AssignFile(Var f:File;c:char);
  30. Procedure CloseFile(Var f:File);
  31. { Text file support }
  32. Procedure AssignFile(Var t:Text;const s:string);
  33. Procedure AssignFile(Var t:Text;p:pchar);
  34. Procedure AssignFile(Var t:Text;c:char);
  35. Procedure CloseFile(Var t:Text);
  36. { Typed file supoort }
  37. Procedure AssignFile(Var f:TypedFile;const Name:string);
  38. Procedure AssignFile(Var f:TypedFile;p:pchar);
  39. Procedure AssignFile(Var f:TypedFile;c:char);
  40. { ParamStr should return also an ansistring }
  41. Function ParamStr(Param : Integer) : Ansistring;
  42. implementation
  43. {****************************************************************************
  44. Compatibility routines.
  45. ****************************************************************************}
  46. { Untyped file support }
  47. Procedure AssignFile(Var f:File;const Name:string);
  48. begin
  49. System.Assign (F,Name);
  50. end;
  51. Procedure AssignFile(Var f:File;p:pchar);
  52. begin
  53. System.Assign (F,P);
  54. end;
  55. Procedure AssignFile(Var f:File;c:char);
  56. begin
  57. System.Assign (F,C);
  58. end;
  59. Procedure CloseFile(Var f:File);
  60. begin
  61. System.Close(f);
  62. end;
  63. { Text file support }
  64. Procedure AssignFile(Var t:Text;const s:string);
  65. begin
  66. System.Assign (T,S);
  67. end;
  68. Procedure AssignFile(Var t:Text;p:pchar);
  69. begin
  70. System.Assign (T,P);
  71. end;
  72. Procedure AssignFile(Var t:Text;c:char);
  73. begin
  74. System.Assign (T,C);
  75. end;
  76. Procedure CloseFile(Var t:Text);
  77. begin
  78. Close(T);
  79. end;
  80. { Typed file supoort }
  81. Procedure AssignFile(Var f:TypedFile;const Name:string);
  82. begin
  83. system.Assign(F,Name);
  84. end;
  85. Procedure AssignFile(Var f:TypedFile;p:pchar);
  86. begin
  87. system.Assign (F,p);
  88. end;
  89. Procedure AssignFile(Var f:TypedFile;c:char);
  90. begin
  91. system.Assign (F,C);
  92. end;
  93. Function ParamStr(Param : Integer) : Ansistring;
  94. Var Len : longint;
  95. begin
  96. if (Param>=0) and (Param<argc) then
  97. begin
  98. Len:=0;
  99. While Argv[Param][Len]<>#0 do
  100. Inc(len);
  101. SetLength(Result,Len);
  102. If Len>0 then
  103. Move(Argv[Param][0],Result[1],Len);
  104. end
  105. else
  106. paramstr:='';
  107. end;
  108. end.
  109. {
  110. $Log$
  111. Revision 1.26 1999-07-07 10:04:04 michael
  112. + Paramstr now returns cmdline args >255 chars in ansistring objpas.pp
  113. Revision 1.25 1999/07/06 22:44:22 florian
  114. + implemented a paramstr function which returns an ansistring, nevertheless
  115. it is limited to 255 chars because it maps to the system.paramstr, maybe
  116. we should use cmdline instead
  117. Revision 1.24 1999/05/17 21:52:43 florian
  118. * most of the Object Pascal stuff moved to the system unit
  119. Revision 1.23 1999/05/13 21:54:28 peter
  120. * objpas fixes
  121. Revision 1.22 1999/04/16 20:47:20 florian
  122. + tobject.messagestringtable function for Megido/GTK support
  123. added
  124. Revision 1.21 1999/02/23 14:04:36 pierre
  125. * call %edi => call *%edi
  126. Revision 1.20 1999/02/22 23:30:54 florian
  127. + TObject.Dispatch and TObject.DispatchStr added, working
  128. Revision 1.19 1998/12/24 10:12:03 michael
  129. Implemented AssignFile and CloseFile compatibility
  130. Revision 1.18 1998/10/12 12:42:58 florian
  131. * as operator runtime error can be now caught by an errorproc
  132. Revision 1.17 1998/10/05 12:32:53 peter
  133. + assert() support
  134. Revision 1.16 1998/10/03 15:07:16 florian
  135. + TObject.AfterConstruction and TObject.BeforeDestruction of Delphi 4
  136. Revision 1.15 1998/09/24 16:13:48 michael
  137. Changes in exception and open array handling
  138. Revision 1.14 1998/09/23 12:40:43 michael
  139. Fixed TVarRec again. Should be OK now
  140. Revision 1.13 1998/09/23 12:18:32 michael
  141. + added VType in TVArRec
  142. Revision 1.12 1998/09/23 10:00:47 peter
  143. * tvarrec should be 8 bytes
  144. Revision 1.11 1998/09/22 15:30:07 peter
  145. * array of const update
  146. Revision 1.9 1998/09/16 13:08:19 michael
  147. Added AbstractErrorHandler
  148. Revision 1.8 1998/09/06 21:27:31 florian
  149. + method tobject.classinfo added
  150. Revision 1.7 1998/09/04 08:49:06 peter
  151. * 0.99.5 doesn't compile a whole objpas anymore to overcome crashes
  152. Revision 1.6 1998/08/23 20:58:52 florian
  153. + rtti for objects and classes
  154. + TObject.GetClassName implemented
  155. Revision 1.5 1998/07/30 16:10:11 michael
  156. + Added support for ExceptProc+
  157. Revision 1.4 1998/07/29 15:44:33 michael
  158. included sysutils and math.pp as target. They compile now.
  159. Revision 1.3 1998/07/29 10:09:28 michael
  160. + put in exception support
  161. Revision 1.2 1998/03/25 23:40:24 florian
  162. + stuff from old objpash.inc and objpas.inc merged in
  163. }