objects.pas 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082
  1. {**********[ SOURCE FILE OF FREE VISION ]***************}
  2. { }
  3. { Parts Copyright (c) 1992,96 by Florian Klaempfl }
  4. { [email protected] }
  5. { }
  6. { Parts Copyright (c) 1996 by Frank ZAGO }
  7. { [email protected] }
  8. { }
  9. { Parts Copyright (c) 1995 by MH Spiegel }
  10. { }
  11. { Parts Copyright (c) 1996 by Leon de Boer }
  12. { [email protected] }
  13. { }
  14. { THIS CODE IS FREEWARE }
  15. {*******************************************************}
  16. {***************[ SUPPORTED PLATFORMS ]*****************}
  17. { 16 and 32 Bit compilers }
  18. { DOS - Turbo Pascal 7.0 + (16 Bit) }
  19. { - FPK Pascal (32 Bit) }
  20. { DPMI - Turbo Pascal 7.0 + (16 Bit) }
  21. { WINDOWS - Turbo Pascal 7.0 + (16 Bit) }
  22. { OS2 - Virtual Pascal 0.3 + (32 Bit) }
  23. { SpeedPascal 1.5 G + (32 Bit) }
  24. { C'T patch to BP (16 Bit) }
  25. {*******************************************************}
  26. UNIT Objects;
  27. {$I os.inc}
  28. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  29. INTERFACE
  30. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  31. { ******************************* REMARK ****************************** }
  32. { FPK does not accept $IFNDEF compiler defines and mishandles $IFDEF }
  33. { with constants. Can we please get this error fixed!!!!! }
  34. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  35. {====Compiler conditional defines to sort platforms out =============}
  36. {$DEFINE NotFPKPascal} { Predefine Not FPK }
  37. {$DEFINE NotOS2} { Predefine NOT OS2 }
  38. {$IFDEF FPK} { FPK PASCAL }
  39. {$DEFINE FPKPascal} { Set FPK definition }
  40. {$DEFINE DOS_OS} { Define DOS_OS }
  41. {$DEFINE CODE_32_BIT} { 32 BIT CODE }
  42. {$UNDEF USE_BGI} { Can't use BGI }
  43. {$UNDEF NotFPKPascal} { This is FPK pascal }
  44. {$ENDIF}
  45. {$IFDEF MSDOS} { MSDOS PLATFORM }
  46. {$DEFINE DOS_OS} { Define DOS_OS }
  47. {$ENDIF}
  48. {$IFDEF DPMI} { DPMI PLATFORM }
  49. {$DEFINE DOS_OS} { Define DOS_OS }
  50. {$ENDIF}
  51. {$IFDEF Windows} { WINDOWS platform }
  52. {$DEFINE ADV_OS} { Set as advanced }
  53. {$UNDEF USE_BGI} { Can't use BGI }
  54. {$ENDIF}
  55. {$IFDEF OS2} { OS2 platform }
  56. {$DEFINE ADV_OS} { Set as advanced }
  57. {$IFNDEF FPK}
  58. {$DEFINE BPOS2} { Define BPOS2 }
  59. {$ENDIF FPK}
  60. {$UNDEF NotOS2} { This is OS2 compiler }
  61. {$UNDEF USE_BGI} { Can't use BGI }
  62. {$UNDEF DOS_OS}
  63. {$ENDIF}
  64. {$IFDEF VirtualPascal} { VIRTUAL PASCAL }
  65. {$DEFINE CODE_32_BIT} { 32 BIT CODE }
  66. {$DEFINE ASM_32_BIT} { 32 BIT ASSSEMBLER }
  67. {$DEFINE API_32_BIT} { 32 BIT API CALLS }
  68. {$UNDEF BPOS2} { Undefine BPOS2 }
  69. {$ENDIF}
  70. {$IFDEF Speed} { SPEED PASCAL }
  71. {$DEFINE CODE_32_BIT} { 32 BIT CODE }
  72. {$DEFINE ASM_32_BIT} { 32 BIT ASSSEMBLER }
  73. {$DEFINE API_32_BIT} { 32 BIT API CALLS }
  74. {$UNDEF BPOS2} { Undefine BPOS2 }
  75. {$ENDIF}
  76. {--------------------------------------------------------------------}
  77. { ******************************* REMARK ****************************** }
  78. { How about FPK accepting all the standard compiler directives even if }
  79. { It just ignores them for now!! }
  80. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  81. {==== Compiler directives ===========================================}
  82. {$IFDEF FPKPascal} { FPK PASCAL }
  83. {$E-}
  84. {$DEFINE NoExceptions}
  85. {$DEFINE SString}
  86. CONST
  87. Sw_MaxData = 128*1024*1024; { Maximum data size }
  88. TYPE
  89. Sw_Word = LongInt; { Long integer now }
  90. Sw_Integer = LongInt; { Long integer now }
  91. TYPE
  92. FuncPtr = FUNCTION (Item: Pointer; _EBP: Sw_Word): Boolean;
  93. ProcPtr = PROCEDURE (Item: Pointer; _EBP: Sw_Word);
  94. {$ENDIF}
  95. {$IFDEF NotFPKPascal} { ALL OTHER COMPILERS }
  96. {$N-} { No 80x87 code generation }
  97. {$O+} { This unit may be overlaid }
  98. {$X+} { Extended syntax is ok }
  99. {$F+} { Force far calls }
  100. {$A+} { Word Align Data }
  101. {$G+} { 286 Code optimization - if you're on an 8088 get a real computer }
  102. {$R-} { Disable range checking }
  103. {$S-} { Disable Stack Checking }
  104. {$I-} { Disable IO Checking }
  105. {$Q-} { Disable Overflow Checking }
  106. {$V-} { Turn off strict VAR strings }
  107. {$B-} { Allow short circuit boolean evaluations }
  108. {$IFNDEF CODE_32_BIT} { 16 BIT DEFINITIONS }
  109. CONST
  110. Sw_MaxData = 65520; { Maximum data size }
  111. TYPE
  112. Sw_Word = Word; { Standard word }
  113. Sw_Integer = Integer; { Standard integer }
  114. {$ELSE} { 32 BIT DEFINITIONS }
  115. CONST
  116. Sw_MaxData = 128*1024*1024; { Maximum data size }
  117. TYPE
  118. Sw_Word = LongInt; { Long integer now }
  119. Sw_Integer = LongInt; { Long integer now }
  120. {$ENDIF}
  121. TYPE
  122. {$IFDEF VirtualPascal} { VP is different }
  123. FuncPtr = FUNCTION (Item: Pointer): Boolean;
  124. {$ELSE} { All others }
  125. FuncPtr = FUNCTION (Item: Pointer; _EBP: Sw_Word): Boolean;
  126. {$ENDIF}
  127. TYPE
  128. {$IFDEF VirtualPascal} { VP is different }
  129. ProcPtr = PROCEDURE (Item: Pointer);
  130. {$ELSE} { All others }
  131. ProcPtr = PROCEDURE (Item: Pointer; _EBP: Sw_Word);
  132. {$ENDIF}
  133. {$ENDIF}
  134. {---------------------------------------------------------------------}
  135. CONST
  136. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  137. {Þ STREAM ERROR STATE MASKS Ý}
  138. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  139. stOk = 0; { No stream error }
  140. stError = -1; { Access error }
  141. stInitError = -2; { Initialize error }
  142. stReadError = -3; { Stream read error }
  143. stWriteError = -4; { Stream write error }
  144. stGetError = -5; { Get object error }
  145. stPutError = -6; { Put object error }
  146. stSeekError = -7; { Seek error in stream }
  147. stOpenError = -8; { Error opening stream }
  148. CONST
  149. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  150. {Þ STREAM ACCESS MODE CONSTANTS Ý}
  151. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  152. stCreate = $3C00; { Create new file }
  153. stOpenRead = $3D00; { Read access only }
  154. stOpenWrite = $3D01; { Write access only }
  155. stOpen = $3D02; { Read/write access }
  156. CONST
  157. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  158. {Þ TCollection ERROR CODES Ý}
  159. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  160. coIndexError = -1; { Index out of range }
  161. coOverflow = -2; { Overflow }
  162. CONST
  163. { ******************************* REMARK ****************************** }
  164. { These are completely NEW FREE VISION ONLY constants that are used }
  165. { in conjuction with CreateStream a NEW FREE VISION call. This call }
  166. { tries creating a stream in the order of the Strategy Mask and will }
  167. { return the successfully created stream or nil if it fails. }
  168. { ****************************** END REMARK *** Leon de Boer, 15May96 * }
  169. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  170. {Þ STREAM CREATE STRATEGY MASKS Ý}
  171. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  172. sa_XMSFirst = $8000; { Use XMS memory 1st }
  173. sa_EMSFirst = $4000; { Use EMS memory 1st }
  174. sa_RAMFirst = $2000; { Use RAM memory 1st }
  175. sa_DISKFirst = $1000; { Use DISK space 1st }
  176. sa_XMSSecond = $0800; { Use XMS memory 2nd }
  177. sa_EMSSecond = $0400; { Use EMS memory 2nd }
  178. sa_RAMSecond = $0200; { Use RAM memory 2nd }
  179. sa_DISKSecond = $0100; { Use DISK space 2nd }
  180. sa_XMSThird = $0080; { Use XMS memory 3rd }
  181. sa_EMSThird = $0040; { Use EMS memory 3rd }
  182. sa_RAMThird = $0020; { Use RAM memory 3rd }
  183. sa_DISKThird = $0010; { Use DISK space 3rd }
  184. sa_XMSFourth = $0008; { Use XMS memory 4th }
  185. sa_EMSFourth = $0004; { Use EMS memory 4th }
  186. sa_RAMFourth = $0002; { Use RAM memory 4th }
  187. sa_DISKFourth = $0001; { Use DISK space 4th }
  188. CONST
  189. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  190. {Þ GENERAL USE CONSTANTS Ý}
  191. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  192. {$IFDEF VirtualPascal}
  193. vmtHeaderSize = 12; { VMT header size }
  194. {$ELSE}
  195. vmtHeaderSize = 8; { VMT header size }
  196. {$ENDIF}
  197. CONST
  198. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  199. {Þ MAXIMUM COLLECTION SIZE CONSTANT Ý}
  200. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  201. MaxCollectionSize = Sw_MaxData DIV SizeOf(Pointer);{ Max collection size }
  202. TYPE
  203. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  204. {Þ CHARACTER SET Ý}
  205. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  206. TCharSet = SET Of Char; { Character set }
  207. PCharSet = ^TCharSet; { Character set ptr }
  208. TYPE
  209. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  210. {Þ GENERAL ARRAYS Ý}
  211. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  212. TByteArray = ARRAY [0..Sw_MaxData-1] Of Byte; { Byte array }
  213. PByteArray = ^TByteArray; { Byte array pointer }
  214. TWordArray = ARRAY [0..Sw_MaxData DIV 2-1] Of Word;{ Word array }
  215. PWordArray = ^TWordArray; { Word array pointer }
  216. TYPE
  217. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  218. {Þ DOS FILENAME STRING Ý}
  219. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  220. {$IFDEF DOS_OS} { DOS/DPMI DEFINE }
  221. FNameStr = String[79]; { DOS filename }
  222. {$ENDIF}
  223. {$IFDEF Windows} { WINDOWS DEFINE }
  224. FNameStr = PChar; { Windows filename }
  225. {$ENDIF}
  226. {$IFDEF OS2} { OS2 DEFINE }
  227. FNameStr = String; { OS2 filename }
  228. {$ENDIF}
  229. TYPE
  230. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  231. {Þ DOS ASCIIZ FILENAME Ý}
  232. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  233. AsciiZ = Array [0..255] Of Char; { Filename array }
  234. TYPE
  235. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  236. {Þ GENERAL TYPE POINTERS Ý}
  237. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  238. PByte = ^Byte; { Byte pointer }
  239. PWord = ^Word; { Word pointer }
  240. PLongInt = ^LongInt; { LongInt pointer }
  241. PString = ^String; { String pointer }
  242. {***************************************************************************}
  243. { RECORD DEFINITIONS }
  244. {***************************************************************************}
  245. TYPE
  246. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  247. {Þ TYPE CONVERSION RECORDS Ý}
  248. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  249. WordRec = RECORD
  250. Lo, Hi: Byte; { Word to bytes }
  251. END;
  252. LongRec = RECORD
  253. Lo, Hi: Word; { LongInt to words }
  254. END;
  255. PtrRec = RECORD
  256. Ofs, Seg: Word; { Pointer to words }
  257. END;
  258. TYPE
  259. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  260. {Þ TStreamRec RECORD - STREAM OBJECT RECORD Ý}
  261. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  262. PStreamRec = ^TStreamRec; { Stream record ptr }
  263. TStreamRec = RECORD
  264. ObjType: Sw_Word; { Object type id }
  265. VmtLink: Sw_Word; { VMT link }
  266. Load : Pointer; { Object load code }
  267. Store: Pointer; { Object store code }
  268. Next : Sw_Word; { Bytes to next }
  269. END;
  270. {***************************************************************************}
  271. { OBJECT DEFINITIONS }
  272. {***************************************************************************}
  273. TYPE
  274. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  275. {Þ TPoint RECORD - POINT RECORD Ý}
  276. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  277. TPoint = RECORD
  278. X, Y: Integer; { Point co-ordinates }
  279. END;
  280. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  281. {Þ TRect OBJECT - RECTANGLE OBJECT Ý}
  282. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  283. TRect = OBJECT
  284. A, B: TPoint; { Corner points }
  285. FUNCTION Empty: Boolean;
  286. FUNCTION Equals (R: TRect): Boolean;
  287. FUNCTION Contains (P: TPoint): Boolean;
  288. PROCEDURE Copy (R: TRect);
  289. PROCEDURE Union (R: TRect);
  290. PROCEDURE Intersect (R: TRect);
  291. PROCEDURE Move (ADX, ADY: Integer);
  292. PROCEDURE Grow (ADX, ADY: Integer);
  293. PROCEDURE Assign (XA, YA, XB, YB: Integer);
  294. END;
  295. PRect = ^TRect;
  296. TYPE
  297. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  298. {Þ TObject OBJECT - BASE ANCESTOR OBJECT Ý}
  299. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  300. TObject = OBJECT
  301. CONSTRUCTOR Init;
  302. PROCEDURE Free;
  303. DESTRUCTOR Done; Virtual;
  304. END;
  305. PObject = ^TObject;
  306. TYPE
  307. { ******************************* REMARK ****************************** }
  308. { Two new virtual methods have been added to the object in the form of }
  309. { Close and Open. The main use here is in the Disk Based Descendants }
  310. { the calls open and close the given file so these objects can be }
  311. { used like standard files. All existing code will compile and work }
  312. { completely normally oblivious to these new methods. }
  313. { ****************************** END REMARK *** Leon de Boer, 15May96 * }
  314. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  315. {Þ TStream OBJECT - STREAM ANCESTOR OBJECT Ý}
  316. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  317. TStream = OBJECT (TObject)
  318. Status : Integer; { Stream status }
  319. ErrorInfo: Integer; { Stream error info }
  320. FUNCTION Get: PObject;
  321. FUNCTION StrRead: PChar;
  322. FUNCTION GetPos: LongInt; Virtual;
  323. FUNCTION GetSize: LongInt; Virtual;
  324. FUNCTION ReadStr: PString;
  325. PROCEDURE Close; Virtual;
  326. PROCEDURE Reset;
  327. PROCEDURE Flush; Virtual;
  328. PROCEDURE Truncate; Virtual;
  329. PROCEDURE Put (P: PObject);
  330. PROCEDURE Seek (Pos: LongInt); Virtual;
  331. PROCEDURE StrWrite (P: PChar);
  332. PROCEDURE WriteStr (P: PString);
  333. PROCEDURE Open (OpenMode: Word); Virtual;
  334. PROCEDURE Error (Code, Info: Integer); Virtual;
  335. PROCEDURE Read (Var Buf; Count: Sw_Word); Virtual;
  336. PROCEDURE Write (Var Buf; Count: Sw_Word); Virtual;
  337. PROCEDURE CopyFrom (Var S: TStream; Count: Longint);
  338. END;
  339. PStream = ^TStream;
  340. TYPE
  341. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  342. {Þ TDosStream OBJECT - DOS FILE STREAM OBJECT Ý}
  343. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  344. TDosStream = OBJECT (TStream)
  345. Handle: Integer; { DOS file handle }
  346. FName : AsciiZ; { AsciiZ filename }
  347. CONSTRUCTOR Init (FileName: FNameStr; Mode: Word);
  348. DESTRUCTOR Done; Virtual;
  349. FUNCTION GetPos: Longint; Virtual;
  350. FUNCTION GetSize: Longint; Virtual;
  351. PROCEDURE Close; Virtual;
  352. PROCEDURE Seek (Pos: LongInt); Virtual;
  353. PROCEDURE Open (OpenMode: Word); Virtual;
  354. PROCEDURE Read (Var Buf; Count: Sw_Word); Virtual;
  355. PROCEDURE Write (Var Buf; Count: Sw_Word); Virtual;
  356. END;
  357. PDosStream = ^TDosStream;
  358. TYPE
  359. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  360. {Þ TBufStream OBJECT - BUFFERED DOS FILE STREAM Ý}
  361. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  362. TBufStream = OBJECT (TDosStream)
  363. END;
  364. PBufStream = ^TBufStream;
  365. TYPE
  366. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  367. {Þ TEmsStream OBJECT - EMS STREAM OBJECT Ý}
  368. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  369. TEmsStream = OBJECT (TStream)
  370. END;
  371. PEmsStream = ^TEmsStream;
  372. TYPE
  373. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  374. {Þ TXmsStream OBJECT - XMS STREAM OBJECT Ý}
  375. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  376. TXmsStream = OBJECT (TStream)
  377. END;
  378. PXmsStream = ^TXmsStream;
  379. TYPE
  380. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  381. {Þ TMemoryStream OBJECT - MEMORY STREAM OBJECT Ý}
  382. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  383. TMemoryStream = OBJECT (TStream)
  384. END;
  385. PMemoryStream = ^TMemoryStream;
  386. TYPE
  387. TItemList = Array [0..MaxCollectionSize - 1] Of Pointer;
  388. PItemList = ^TItemList;
  389. { ******************************* REMARK ****************************** }
  390. { The changes here look worse than they are. The Sw_Integer simply }
  391. { switches between Integers and LongInts if switched between 16 and 32 }
  392. { bit code. All existing code will compile without any changes. }
  393. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  394. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  395. {Þ TCollection OBJECT - COLLECTION ANCESTOR OBJECT Ý}
  396. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  397. TCollection = OBJECT (TObject)
  398. Items: PItemList; { Item list pointer }
  399. Count: Sw_Integer; { Item count }
  400. Limit: Sw_Integer; { Item limit count }
  401. Delta: Sw_Integer; { Inc delta size }
  402. CONSTRUCTOR Init (ALimit, ADelta: Sw_Integer);
  403. CONSTRUCTOR Load (Var S: TStream);
  404. DESTRUCTOR Done; Virtual;
  405. FUNCTION At (Index: Sw_Integer): Pointer;
  406. FUNCTION IndexOf (Item: Pointer): Sw_Integer; Virtual;
  407. FUNCTION GetItem (Var S: TStream): Pointer; Virtual;
  408. FUNCTION LastThat (Test: Pointer): Pointer;
  409. FUNCTION FirstThat (Test: Pointer): Pointer;
  410. PROCEDURE Pack;
  411. PROCEDURE FreeAll;
  412. PROCEDURE DeleteAll;
  413. PROCEDURE Free (Item: Pointer);
  414. PROCEDURE Insert (Item: Pointer); Virtual;
  415. PROCEDURE Delete (Item: Pointer);
  416. PROCEDURE AtFree (Index: Sw_Integer);
  417. PROCEDURE FreeItem (Item: Pointer); Virtual;
  418. PROCEDURE AtDelete (Index: Sw_Integer);
  419. PROCEDURE ForEach (Action: Pointer);
  420. PROCEDURE SetLimit (ALimit: Sw_Integer); Virtual;
  421. PROCEDURE Error (Code, Info: Integer); Virtual;
  422. PROCEDURE AtPut (Index: Sw_Integer; Item: Pointer);
  423. PROCEDURE AtInsert (Index: Sw_Integer; Item: Pointer);
  424. PROCEDURE Store (Var S: TStream);
  425. PROCEDURE PutItem (Var S: TStream; Item: Pointer); Virtual;
  426. END;
  427. PCollection = ^TCollection;
  428. TYPE
  429. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  430. {Þ TSortedCollection OBJECT - SORTED COLLECTION ANCESTOR Ý}
  431. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  432. TSortedCollection = OBJECT (TCollection)
  433. Duplicates: Boolean; { Duplicates flag }
  434. CONSTRUCTOR Init (ALimit, ADelta: Sw_Integer);
  435. CONSTRUCTOR Load (Var S: TStream);
  436. FUNCTION KeyOf (Item: Pointer): Pointer; Virtual;
  437. FUNCTION IndexOf (Item: Pointer): Sw_Integer; Virtual;
  438. FUNCTION Compare (Key1, Key2: Pointer): Sw_Integer; Virtual;
  439. FUNCTION Search (Key: Pointer; Var Index: Sw_Integer): Boolean;Virtual;
  440. PROCEDURE Insert (Item: Pointer); Virtual;
  441. PROCEDURE Store (Var S: TStream);
  442. END;
  443. PSortedCollection = ^TSortedCollection;
  444. TYPE
  445. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  446. {Þ TStringCollection OBJECT - STRING COLLECTION OBJECT Ý}
  447. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  448. TStringCollection = OBJECT (TSortedCollection)
  449. FUNCTION GetItem (Var S: TStream): Pointer; Virtual;
  450. FUNCTION Compare (Key1, Key2: Pointer): Sw_Integer; Virtual;
  451. PROCEDURE FreeItem (Item: Pointer); Virtual;
  452. PROCEDURE PutItem (Var S: TStream; Item: Pointer); Virtual;
  453. END;
  454. PStringCollection = ^TStringCollection;
  455. TYPE
  456. { ******************************* REMARK ****************************** }
  457. { This is a completely NEW FREE VISION ONLY object which holds a }
  458. { collection of strings but does not alphabetically sort them. It is }
  459. { a very useful object as you will find !!!! }
  460. { ****************************** END REMARK *** Leon de Boer, 15May96 * }
  461. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  462. {Þ TUnSortedStrCollection - UNSORTED STRING COLLECTION OBJECT Ý}
  463. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  464. TUnSortedStrCollection = OBJECT (TStringCollection)
  465. PROCEDURE Insert (Item: Pointer); Virtual;
  466. END;
  467. PUnSortedStrCollection = ^TUnSortedStrCollection;
  468. {***************************************************************************}
  469. { INTERFACE ROUTINES }
  470. {***************************************************************************}
  471. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  472. {Þ DYNAMIC STRING INTERFACE ROUTINES Ý}
  473. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  474. FUNCTION NewStr (Const S: String): PString;
  475. PROCEDURE DisposeStr (P: PString);
  476. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  477. {Þ STREAM INTERFACE ROUTINES Ý}
  478. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  479. PROCEDURE Abstract;
  480. PROCEDURE RegisterError;
  481. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  482. {Þ NEW FREE VISION STREAM ROUTINES Ý}
  483. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  484. { ******************************* REMARK ****************************** }
  485. { This NEW FREE VISION call tries creating a stream in the order of }
  486. { the Strategy Mask and will return the successfully created stream }
  487. { or nil if it fails using the strategy given. }
  488. { ****************************** END REMARK *** Leon de Boer, 15May96 * }
  489. FUNCTION CreateStream (Strategy: Word; ReqSize: LongInt): PStream;
  490. { ******************************* REMARK ****************************** }
  491. { As we have to provide these NEW FREE VISION CALLS as part of our }
  492. { stream support we might as well provide them on the interface! They }
  493. { mimic the behaviour of the OS2 API calls in most cases. }
  494. { ****************************** END REMARK *** Leon de Boer, 16May96 * }
  495. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  496. {Þ NEW FREE VISION DOS FILE ROUTINES Ý}
  497. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  498. {=DosFileOpen=========================================================
  499. Calls the operating system to try to open the file denoted by the given
  500. AsciiZ filename in the requested file mode. Any error is held in
  501. DosStreamError and the call will return zero. If successful and no error
  502. occurs the call will return the file handle of the opened file.
  503. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB
  504. =====================================================================}
  505. FUNCTION DosFileOpen (Var FileName: AsciiZ; Mode: Word): Word;
  506. {=DosRead============================================================
  507. Calls the operating system to read BufferLength bytes of data from
  508. the file denoted by the handle to the bufferarea. Any error in attempting
  509. to read from the file is held in DosStreamError and returned from call.
  510. If the return is zero (ie no error) BytesMoved contains the number of
  511. bytes read from the file.
  512. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB
  513. =====================================================================}
  514. FUNCTION DosRead(Handle: Word; Var BufferArea; BufferLength: Sw_Word;
  515. Var BytesMoved: Sw_Word): Word;
  516. {=DosWrite===========================================================
  517. Calls the operating system to write to BufferLength bytes of data from
  518. the bufferarea to the file denoted by the handle. Any error in attempting
  519. to write to the file is held in DosStreamError and returned from call.
  520. If the return is zero (ie no error) BytesMoved contains the number of
  521. bytes written to the file.
  522. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB
  523. =====================================================================}
  524. FUNCTION DosWrite(Handle: Word; Var BufferArea; BufferLength: Sw_Word;
  525. Var BytesMoved: Sw_Word): Word;
  526. {=DosSetFilePtr======================================================
  527. Calls the operating system to move the file denoted by the handle to
  528. to the requested position. The move method can be: 0 = absolute offset;
  529. 1 = offset from present location; 2 = offset from end of file;
  530. Any error is held in DosErrorStream and returned from the call.
  531. If the return is zero (ie no error) NewPos contains the new absolute
  532. file position.
  533. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB
  534. =====================================================================}
  535. FUNCTION DosSetFilePtr (Handle: Word; Pos: LongInt; MoveType: Word;
  536. Var NewPos: LongInt): Word;
  537. {=DosClose===========================================================
  538. Calls the operating system to close the file handle provided. Any error
  539. in attempting to close file is held DosErrorStream.
  540. -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB
  541. =====================================================================}
  542. PROCEDURE DosClose (Handle: Word);
  543. CONST
  544. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  545. {Þ INITIALIZED PUBLIC VARIABLES Ý}
  546. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  547. StreamError: Pointer = Nil; { Stream error ptr }
  548. {$IFDEF NotFPKPascal}
  549. DosStreamError: Sw_Word = $0; { Dos stream error }
  550. {$ENDIF}
  551. { ******************************* REMARK ****************************** }
  552. { FPK does not accept local variables with it's assembler which means }
  553. { these have to be global. Can we please get this error fixed!!!!! }
  554. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  555. {$IFDEF FPKPascal} { FPK Pascal compiler }
  556. VAR HoldEBP: Sw_Word; TransferHandle: Sw_Word;
  557. DosStreamError: Sw_Word ; { Dos stream error }
  558. {$ENDIF}
  559. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  560. IMPLEMENTATION
  561. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  562. {$IFDEF Windows} { WINDOWS CODE }
  563. USES WinTypes, WinProcs; { Standard units }
  564. {$ENDIF}
  565. {$IFDEF Speed} { SPEED PASCAL CODE }
  566. USES BseDos; { Speed Pascal def }
  567. {$ENDIF}
  568. {$IFDEF VirtualPascal} { VIRTUAL PASCAL CODE }
  569. USES OS2Base; { Virtual Pascal base }
  570. {$ENDIF}
  571. {$IFDEF BPOS2} { C'T PATCH TO BP CODE }
  572. FUNCTION DosClose (Handle: Word): Word; FAR;
  573. EXTERNAL 'DOSCALLS' Index 59; { Dos close function }
  574. FUNCTION DosOpen (FileName: PChar; Var Handle: Word;
  575. Var ActionTaken: Word; FileSize: LongInt;
  576. FileAttr: Word; OpenFlag, OpenMode: Word;
  577. Reserved: Pointer): Word; FAR;
  578. EXTERNAL 'DOSCALLS' Index 70; { Dos open function }
  579. FUNCTION DosRead(Handle: Word; Var BufferArea;
  580. BufferLength: Word; Var BytesRead : Word): Word; FAR;
  581. EXTERNAL 'DOSCALLS' Index 137; { Dos read procedure }
  582. FUNCTION DosWrite(Handle: Word; Var BufferArea;
  583. BufferLength: Word; Var BytesRead : Word): Word; FAR;
  584. EXTERNAL 'DOSCALLS' Index 138; { Dos write procedure }
  585. FUNCTION DosSetFilePtr (Handle: Word; ulOffset: LongInt;
  586. MoveType: Word; Var NewPointer: LongInt): LongInt; FAR;
  587. EXTERNAL 'DOSCALLS' Index 58; { Dos write procedure }
  588. {$ENDIF}
  589. {$IFDEF OS2} { OS2 CODE }
  590. CONST
  591. { Private Os2 File mode magic numbers }
  592. FmInput = $20; { Open file for input }
  593. FmOutput = $31; { Open file for output }
  594. FmInout = $42; { Open file }
  595. FmClosed = $0; { Close file }
  596. {$ENDIF}
  597. {$IFDEF DPMI} { DPMI CODE }
  598. {$DEFINE NewExeFormat} { New format EXE }
  599. {$ENDIF}
  600. {$IFDEF ADV_OS} { WINDOWS/OS2 CODE }
  601. {$DEFINE NewExeFormat} { New format EXE }
  602. {$ENDIF}
  603. CONST
  604. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  605. {Þ INITIALIZED PRIVATE VARIABLES Ý}
  606. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  607. StreamTypes: Sw_Word = $0; { Stream types }
  608. {***************************************************************************}
  609. { OBJECT METHODS }
  610. {***************************************************************************}
  611. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  612. {Þ TRect OBJECT METHODS Ý}
  613. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  614. PROCEDURE CheckEmpty (Var Rect: TRect);
  615. { ******************************* REMARK ****************************** }
  616. { This is is my desired code but FPK does not like the with statement }
  617. { Can we please get this error fixed!!!!! }
  618. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  619. { With Rect Do Begin }
  620. { If (A.X >= B.X) OR (A.Y >= B.Y) Then Begin } { Zero of reversed }
  621. { A.X := 0; } { Clear a.x }
  622. { A.Y := 0; } { Clear a.y }
  623. { B.X := 0; } { Clear b.x }
  624. { B.Y := 0; } { Clear b.y }
  625. { End; }
  626. { End; }
  627. BEGIN
  628. If (Rect.A.X >= Rect.B.X) OR
  629. (Rect.A.Y >= Rect.B.Y) Then Begin { Zero of reversed }
  630. Rect.A.X := 0; { Clear a.x }
  631. Rect.A.Y := 0; { Clear a.y }
  632. Rect.B.X := 0; { Clear b.x }
  633. Rect.B.Y := 0; { Clear b.y }
  634. End;
  635. END;
  636. { ******************************* REMARK ****************************** }
  637. { This is a bug fix of EMPTY from the original code which was: }
  638. { Empty := (A.X = B.X) AND (A.Y = B.Y) }
  639. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  640. {**TRect********************************************************************}
  641. { Empty -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  642. {***************************************************************************}
  643. FUNCTION TRect.Empty: Boolean;
  644. BEGIN
  645. Empty := (A.X >= B.X) OR (A.Y >= B.Y); { Empty result }
  646. END;
  647. {**TRect********************************************************************}
  648. { Equals -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  649. {***************************************************************************}
  650. FUNCTION TRect.Equals (R: TRect): Boolean;
  651. BEGIN
  652. Equals := (A.X = R.A.X) AND (A.Y = R.A.Y) AND
  653. (B.X = R.B.X) AND (B.Y = R.B.Y); { Equals result }
  654. END;
  655. { ******************************* REMARK ****************************** }
  656. { This is a bug fix of Contains from the original code which was: }
  657. { Contains := (P.X >= A.X) AND (P.X <= B.X) AND }
  658. { (P.Y >= A.Y) AND (P.Y <= B.Y) }
  659. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  660. {**TRect********************************************************************}
  661. { Contains -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  662. {***************************************************************************}
  663. FUNCTION TRect.Contains (P: TPoint): Boolean;
  664. BEGIN
  665. Contains := (P.X >= A.X) AND (P.X < B.X) AND
  666. (P.Y >= A.Y) AND (P.Y < B.Y); { Contains result }
  667. END;
  668. {**TRect********************************************************************}
  669. { Copy -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  670. {***************************************************************************}
  671. PROCEDURE TRect.Copy (R: TRect);
  672. BEGIN
  673. A := R.A; { Copy point a }
  674. B := R.B; { Copy point b }
  675. END;
  676. {**TRect********************************************************************}
  677. { Union -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  678. {***************************************************************************}
  679. PROCEDURE TRect.Union (R: TRect);
  680. BEGIN
  681. If (R.A.X < A.X) Then A.X := R.A.X; { Take if smaller }
  682. If (R.A.Y < A.Y) Then A.Y := R.A.Y; { Take if smaller }
  683. If (R.B.X > B.X) Then B.X := R.B.X; { Take if larger }
  684. If (R.B.Y > B.Y) Then B.Y := R.B.Y; { Take if larger }
  685. END;
  686. {**TRect********************************************************************}
  687. { Intersect -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  688. {***************************************************************************}
  689. PROCEDURE TRect.Intersect (R: TRect);
  690. BEGIN
  691. If (R.A.X > A.X) Then A.X := R.A.X; { Take if larger }
  692. If (R.A.Y > A.Y) Then A.Y := R.A.Y; { Take if larger }
  693. If (R.B.X < B.X) Then B.X := R.B.X; { Take if smaller }
  694. If (R.B.Y < B.Y) Then B.Y := R.B.Y; { Take if smaller }
  695. CheckEmpty(Self); { Check if empty }
  696. END;
  697. {**TRect********************************************************************}
  698. { Move -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  699. {***************************************************************************}
  700. PROCEDURE TRect.Move (ADX, ADY: Integer);
  701. BEGIN
  702. Inc(A.X, ADX); { Adjust A.X }
  703. Inc(A.Y, ADY); { Adjust A.Y }
  704. Inc(B.X, ADX); { Adjust B.X }
  705. Inc(B.Y, ADY); { Adjust B.Y }
  706. END;
  707. {**TRect********************************************************************}
  708. { Grow -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  709. {***************************************************************************}
  710. PROCEDURE TRect.Grow (ADX, ADY: Integer);
  711. BEGIN
  712. Dec(A.X, ADX); { Adjust A.X }
  713. Dec(A.Y, ADY); { Adjust A.Y }
  714. Inc(B.X, ADX); { Adjust B.X }
  715. Inc(B.Y, ADY); { Adjust B.Y }
  716. CheckEmpty(Self); { Check if empty }
  717. END;
  718. {**TRect********************************************************************}
  719. { Assign -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  720. {***************************************************************************}
  721. PROCEDURE TRect.Assign (XA, YA, XB, YB: Integer);
  722. BEGIN
  723. A.X := XA; { Hold A.X value }
  724. A.Y := YA; { Hold A.Y value }
  725. B.X := XB; { Hold B.X value }
  726. B.Y := YB; { Hold B.Y value }
  727. END;
  728. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  729. {Þ TObject OBJECT METHODS Ý}
  730. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  731. TYPE
  732. DummyObject = OBJECT (TObject) { Internal object }
  733. Data: RECORD END; { Helps size VMT link }
  734. END;
  735. { ******************************* REMARK ****************************** }
  736. { I Prefer this code because it self sizes VMT link rather than using a }
  737. { fixed record structure thus it should work on all compilers without a }
  738. { specific record to match each compiler. }
  739. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  740. CONSTRUCTOR TObject.Init;
  741. VAR LinkSize: LongInt; Dummy: DummyObject;
  742. BEGIN
  743. LinkSize := LongInt(@Dummy.Data)-LongInt(@Dummy); { Calc VMT link size }
  744. FillChar(Pointer(LongInt(@Self)+LinkSize)^,
  745. SizeOf(Self)-LinkSize, #0); { Clear data fields }
  746. END;
  747. {**TObject******************************************************************}
  748. { Free -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  749. {***************************************************************************}
  750. PROCEDURE TObject.Free;
  751. BEGIN
  752. Dispose(PObject(@Self), Done); { Dispose of self }
  753. END;
  754. {**TObject******************************************************************}
  755. { Done -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  756. {***************************************************************************}
  757. DESTRUCTOR TObject.Done;
  758. BEGIN { Abstract method }
  759. END;
  760. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  761. {Þ TStream OBJECT METHODS Ý}
  762. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  763. { ******************************* REMARK ****************************** }
  764. { Bug fix of TStream.StrRead from the original code which was: }
  765. { GetMem(P, L+1) can fail and return Nil which should be checked! }
  766. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  767. {**TStream******************************************************************}
  768. { StrRead -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  769. {***************************************************************************}
  770. FUNCTION TStream.StrRead: PChar;
  771. VAR L: Word; P: PChar;
  772. BEGIN
  773. Read(L, SizeOf(L)); { Read length }
  774. If (L=0) Then StrRead := Nil Else Begin { Check for empty }
  775. GetMem(P, L + 1); { Allocate memory }
  776. If (P<>Nil) Then Begin { Check allocate okay }
  777. Read(P[0], L); { Read the data }
  778. P[L] := #0; { Terminate with #0 }
  779. End;
  780. StrRead := P; { Return PChar }
  781. End;
  782. END;
  783. { ******************************* REMARK ****************************** }
  784. { Bug fix of TStream.ReadStr from the original code which was: }
  785. { GetMem(P, L+1) can fail and return Nil which should be checked! }
  786. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  787. {**TStream******************************************************************}
  788. { ReadStr -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  789. {***************************************************************************}
  790. FUNCTION TStream.ReadStr: PString;
  791. VAR L: Byte; P: PString;
  792. BEGIN
  793. Read(L, 1); { Read string length }
  794. If (L > 0) Then Begin
  795. GetMem(P, L + 1); { Allocate memory }
  796. If (P<>Nil) Then Begin { Check allocate okay }
  797. P^[0] := Char(L); { Hold length }
  798. Read(P^[1], L); { Read string data }
  799. End;
  800. ReadStr := P; { Return string ptr }
  801. End Else ReadStr := Nil;
  802. END;
  803. {**TStream******************************************************************}
  804. { GetPos -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  805. {***************************************************************************}
  806. FUNCTION TStream.GetPos: LongInt;
  807. BEGIN { Abstract method }
  808. Abstract; { Abstract error }
  809. END;
  810. {**TStream******************************************************************}
  811. { GetSize -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  812. {***************************************************************************}
  813. FUNCTION TStream.GetSize: LongInt;
  814. BEGIN { Abstract method }
  815. Abstract; { Abstract error }
  816. END;
  817. {**TStream******************************************************************}
  818. { Close -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  819. {***************************************************************************}
  820. PROCEDURE TStream.Close;
  821. BEGIN { Abstract method }
  822. END;
  823. {**TStream******************************************************************}
  824. { Reset -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  825. {***************************************************************************}
  826. PROCEDURE TStream.Reset;
  827. BEGIN
  828. Status := 0; { Clear status }
  829. ErrorInfo := 0; { Clear error info }
  830. END;
  831. {**TStream******************************************************************}
  832. { Flush -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  833. {***************************************************************************}
  834. PROCEDURE TStream.Flush;
  835. BEGIN { Abstract method }
  836. END;
  837. {**TStream******************************************************************}
  838. { Truncate -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  839. {***************************************************************************}
  840. PROCEDURE TStream.Truncate;
  841. BEGIN
  842. Abstract; { Abstract error }
  843. END;
  844. {**TStream******************************************************************}
  845. { Seek -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  846. {***************************************************************************}
  847. PROCEDURE TStream.Seek (Pos: LongInt);
  848. BEGIN
  849. Abstract; { Abstract error }
  850. END;
  851. {**TStream******************************************************************}
  852. { StrWrite -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  853. {***************************************************************************}
  854. PROCEDURE TStream.StrWrite (P: PChar);
  855. VAR L: Word; Q: PByteArray;
  856. BEGIN
  857. L := 0; { Preset no size }
  858. Q := PByteArray(P); { Transfer type }
  859. If (Q<>Nil) Then While (Q^[L]<>0) Do Inc(L); { Calc PChar length }
  860. Write(L, SizeOf(L)); { Store PChar length }
  861. If (P<>Nil) Then Write(P[0], L); { Write data }
  862. END;
  863. {**TStream******************************************************************}
  864. { WriteStr -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  865. {***************************************************************************}
  866. PROCEDURE TStream.WriteStr (P: PString);
  867. CONST Empty: String[1] = '';
  868. BEGIN
  869. If (P<>Nil) Then Write(P^, Length(P^) + 1) { Write string }
  870. Else Write(Empty, 1); { Write empty string }
  871. END;
  872. {**TStream******************************************************************}
  873. { Open -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  874. {***************************************************************************}
  875. PROCEDURE TStream.Open (OpenMode: Word);
  876. BEGIN { Abstract method }
  877. END;
  878. {**TStream******************************************************************}
  879. { Error -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  880. {***************************************************************************}
  881. PROCEDURE TStream.Error (Code, Info: Integer);
  882. TYPE TErrorProc = Procedure(Var S: TStream);
  883. BEGIN
  884. Status := Code; { Hold error code }
  885. ErrorInfo := Info; { Hold error info }
  886. If (StreamError<>Nil) Then
  887. TErrorProc(StreamError)(Self); { Call error ptr }
  888. END;
  889. {**TStream******************************************************************}
  890. { Read -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  891. {***************************************************************************}
  892. PROCEDURE TStream.Read (Var Buf; Count: Sw_Word);
  893. BEGIN
  894. Abstract; { Abstract error }
  895. END;
  896. {**TStream******************************************************************}
  897. { Write -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  898. {***************************************************************************}
  899. PROCEDURE TStream.Write (Var Buf; Count: Sw_Word);
  900. BEGIN
  901. Abstract; { Abstract error }
  902. END;
  903. {**TStream******************************************************************}
  904. { CopyFrom -> Platforms DOS/DPMI/WIN/OS2 - Checked 10May96 LdB }
  905. {***************************************************************************}
  906. PROCEDURE TStream.CopyFrom (Var S: TStream; Count: Longint);
  907. VAR W: Word; Buffer: Array[0..1023] of Byte;
  908. BEGIN
  909. While (Count > 0) Do Begin
  910. If (Count > SizeOf(Buffer)) Then { To much data }
  911. W := SizeOf(Buffer) Else W := Count; { Size to transfer }
  912. S.Read(Buffer, W); { Read from stream }
  913. Write(Buffer, W); { Write to stream }
  914. Dec(Count, W); { Dec write count }
  915. End;
  916. END;
  917. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  918. {Þ TDosStream OBJECT METHODS Ý}
  919. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  920. {**TDosStream***************************************************************}
  921. { Init -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  922. {***************************************************************************}
  923. CONSTRUCTOR TDosStream.Init (FileName: FNameStr; Mode: Word);
  924. BEGIN
  925. Inherited Init; { Call ancestor }
  926. {$IFDEF Windows}
  927. AnsiToOem(FileName, FName); { Ansi to OEM }
  928. {$ELSE}
  929. FileName := FileName+#0; { Make asciiz }
  930. Move(FileName[1], FName, Length(FileName)); { Create asciiz name }
  931. {$ENDIF}
  932. Handle := DosFileOpen(FName, Mode); { Open the file }
  933. If (Handle=0) Then Begin { Open failed }
  934. Error(stInitError, DosStreamError); { Call error }
  935. Status := stInitError; { Set fail status }
  936. Handle := -1; { Set invalid handle }
  937. End;
  938. END;
  939. {**TDosStream***************************************************************}
  940. { Done -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  941. {***************************************************************************}
  942. DESTRUCTOR TDosStream.Done;
  943. BEGIN
  944. If (Handle <> -1) Then DosClose(Handle); { Close the file }
  945. Inherited Done; { Call ancestor }
  946. END;
  947. {**TDosStream***************************************************************}
  948. { GetPos -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  949. {***************************************************************************}
  950. FUNCTION TDosStream.GetPos: LongInt;
  951. VAR NewPosition: LongInt;
  952. BEGIN
  953. If (Status=stOk) Then Begin { Check status okay }
  954. If (Handle = -1) Then DosStreamError := 103 { File not open }
  955. Else DosStreamError := DosSetFilePtr(Handle,
  956. 0, 1, NewPosition); { Get file position }
  957. If (DosStreamError<>0) Then Begin { Check for error }
  958. Error(stError, DosStreamError); { Identify error }
  959. NewPosition := -1; { Invalidate position }
  960. End;
  961. GetPos := NewPosition; { Return file position }
  962. End Else GetPos := -1; { Stream in error }
  963. END;
  964. {**TDosStream***************************************************************}
  965. { GetSize -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  966. {***************************************************************************}
  967. FUNCTION TDosStream.GetSize: LongInt;
  968. VAR CurrentPos, FileEndPos: LongInt;
  969. BEGIN
  970. If (Status=stOk) Then Begin { Check status okay }
  971. If (Handle = -1) Then DosStreamError := 103 { File not open }
  972. Else DosStreamError := DosSetFilePtr(Handle,
  973. 0, 1, CurrentPos); { Current position }
  974. If (DosStreamError=0) Then Begin { Check no errors }
  975. DosStreamError := DosSetFilePtr(Handle, 0, 2,
  976. FileEndPos); { Locate end of file }
  977. If (DosStreamError=0) Then
  978. DosSetFilePtr(Handle, 0, 1, CurrentPos); { Reset position }
  979. End;
  980. If (DosStreamError<>0) Then Begin { Check for error }
  981. Error(stError, DosStreamError); { Identify error }
  982. FileEndPos := -1; { Invalidate size }
  983. End;
  984. GetSize := FileEndPos; { Return file size }
  985. End Else GetSize := -1; { Stream in error }
  986. END;
  987. {**TDosStream***************************************************************}
  988. { Close -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  989. {***************************************************************************}
  990. PROCEDURE TDosStream.Close;
  991. BEGIN
  992. If (Handle <> -1) Then DosClose(Handle); { Close the file }
  993. Handle := -1; { Handle now invalid }
  994. END;
  995. {**TDosStream***************************************************************}
  996. { Seek -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  997. {***************************************************************************}
  998. PROCEDURE TDosStream.Seek (Pos: LongInt);
  999. VAR NewPosition: LongInt;
  1000. BEGIN
  1001. If (Status=stOk) Then Begin { Check status okay }
  1002. If (Pos < 0) Then Pos := 0; { Negatives removed }
  1003. If (Handle = -1) Then DosStreamError := 103 { File not open }
  1004. Else DosStreamError := DosSetFilePtr(Handle,
  1005. Pos, 0, NewPosition); { Set file position }
  1006. If ((DosStreamError<>0) OR (NewPosition<>Pos)) { We have an error }
  1007. Then Begin
  1008. If (DosStreamError<>0) Then { Error was detected }
  1009. Error(stError, DosStreamError) { Specific seek error }
  1010. Else Error(stSeekError, 0); { General seek error }
  1011. End;
  1012. End;
  1013. END;
  1014. {**TDosStream***************************************************************}
  1015. { Open -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  1016. {***************************************************************************}
  1017. PROCEDURE TDosStream.Open (OpenMode: Word);
  1018. BEGIN
  1019. If (Handle = -1) Then Begin { File not open }
  1020. Handle := DosFileOpen(FName, OpenMode); { Open the file }
  1021. If (Handle=0) Then Begin { File open failed }
  1022. Error(stOpenError, DosStreamError); { Call error }
  1023. Handle := -1; { Set invalid handle }
  1024. End;
  1025. End;
  1026. END;
  1027. {**TDosStream***************************************************************}
  1028. { Read -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  1029. {***************************************************************************}
  1030. PROCEDURE TDosStream.Read (Var Buf; Count: Sw_Word);
  1031. VAR BytesMoved: Sw_Word;
  1032. BEGIN
  1033. If (Status=stOk) Then Begin { Check status }
  1034. If (Handle = -1) Then BytesMoved := 0 Else { File not open }
  1035. DosStreamError := DosRead(Handle, Buf, Count,
  1036. BytesMoved); { Read from file }
  1037. If ((DosStreamError<>0) OR (BytesMoved<>Count)) { We have an error }
  1038. Then Begin
  1039. If (DosStreamError<>0) Then { Error was detected }
  1040. Error(stError, DosStreamError) { Specific read error }
  1041. Else Error(stReadError, 0); { General read error }
  1042. End;
  1043. End Else FillChar(Buf, Count, #0); { Error clear buffer }
  1044. END;
  1045. {**TDosStream***************************************************************}
  1046. { Write -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  1047. {***************************************************************************}
  1048. PROCEDURE TDosStream.Write (Var Buf; Count: Sw_Word);
  1049. VAR BytesMoved: Sw_Word;
  1050. BEGIN
  1051. If (Status=stOk) Then Begin
  1052. If (Handle=-1) Then BytesMoved := 0 Else { File not open }
  1053. DosStreamError := DosWrite(Handle, Buf, Count,
  1054. BytesMoved); { Write to file }
  1055. If ((DosStreamError<>0) OR (BytesMoved<>Count)) { We have an error }
  1056. Then Begin
  1057. If (DosStreamError<>0) Then { Error was detected }
  1058. Error(stError, DosStreamError) { Specific write error }
  1059. Else Error(stWriteError, 0); { General write error }
  1060. End;
  1061. End;
  1062. END;
  1063. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1064. {Þ TCollection OBJECT METHODS Ý}
  1065. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1066. CONSTRUCTOR TCollection.Init (ALimit, ADelta: Sw_Integer);
  1067. BEGIN
  1068. Inherited Init; { Call ancestor }
  1069. Delta := ADelta; { Set increment }
  1070. SetLimit(ALimit); { Set limit }
  1071. END;
  1072. CONSTRUCTOR TCollection.Load (Var S: TStream);
  1073. VAR C, I: Sw_Integer;
  1074. BEGIN
  1075. S.Read(Count, SizeOf(Count)); { Read count }
  1076. S.Read(Limit, SizeOf(Limit)); { Read limit }
  1077. S.Read(Delta, SizeOf(Delta)); { Read delta }
  1078. Items := Nil; { Clear item pointer }
  1079. C := Count; { Hold count }
  1080. I := Limit; { Hold limit }
  1081. Count := 0; { Clear count }
  1082. Limit := 0; { Clear limit }
  1083. SetLimit(I); { Set requested limit }
  1084. Count := C; { Set count }
  1085. For I := 0 To C-1 Do AtPut(I, GetItem(S)); { Get each item }
  1086. END;
  1087. DESTRUCTOR TCollection.Done;
  1088. BEGIN
  1089. FreeAll; { Free all items }
  1090. SetLimit(0); { Release all memory }
  1091. END;
  1092. FUNCTION TCollection.At (Index: Sw_Integer): Pointer;
  1093. BEGIN
  1094. If (Index < 0) OR (Index >= Count) Then Begin { Invalid index }
  1095. Error(coIndexError, Index); { Call error }
  1096. At := Nil; { Return nil }
  1097. End Else At := Items^[Index]; { Return item }
  1098. END;
  1099. { ******************************* REMARK ****************************** }
  1100. { Bug fix of TCollection.IndexOf from the original code which was: }
  1101. { For I := 0 To Count-1 Do <- What happens if count=0!!!! }
  1102. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  1103. FUNCTION TCollection.IndexOf (Item: Pointer): Sw_Integer;
  1104. VAR I: Sw_Integer;
  1105. BEGIN
  1106. If (Count>0) Then Begin { Count is positive }
  1107. For I := 0 To Count-1 Do { For each item }
  1108. If (Items^[I]=Item) Then Begin { Look for match }
  1109. IndexOf := I; { Return index }
  1110. Exit; { Now exit }
  1111. End;
  1112. End;
  1113. IndexOf := -1; { Return index }
  1114. END;
  1115. FUNCTION TCollection.GetItem (Var S: TStream): Pointer;
  1116. BEGIN
  1117. GetItem := S.Get; { Item off stream }
  1118. END;
  1119. FUNCTION TCollection.LastThat (Test: Pointer): Pointer;
  1120. VAR I: LongInt; P: FuncPtr; {$IFDEF NotFPKPascal} Hold_EBP: Sw_Word; {$ENDIF}
  1121. BEGIN
  1122. {$IFDEF FPKPascal} { FPK pascal compiler }
  1123. ASM
  1124. MOVL (%EBP), %EAX; { Load EBP }
  1125. MOVL %EAX, U_OBJECTS_HOLDEBP; { Store to global }
  1126. END;
  1127. {$ELSE} { Other compilers }
  1128. ASM
  1129. {$IFNDEF CODE_32_BIT} { 16 BIT CODE }
  1130. MOV AX, [BP]; { Load AX from BP }
  1131. {$IFDEF Windows}
  1132. AND AL, 0FEH; { Windows make even }
  1133. {$ENDIF}
  1134. MOV Hold_EBP, AX; { Hold value }
  1135. {$ELSE} { 32 BIT CODE }
  1136. MOV EAX, [EBP]; { Load EAX from EBP }
  1137. MOV Hold_EBP, EAX; { Hold value }
  1138. {$ENDIF}
  1139. END;
  1140. {$ENDIF}
  1141. P := FuncPtr(Test); { Set function ptr }
  1142. For I := Count DownTo 1 Do Begin { Down from last item }
  1143. {$IFDEF FPKPascal}
  1144. {$$$$$ crahes the compiler
  1145. If P(Items^[I-1], HoldEBP) Then
  1146. } Begin { Test each item }
  1147. {$ELSE}
  1148. {$IFDEF VirtualPascal}
  1149. If P(Items^[I-1]) Then Begin { Test each item }
  1150. {$ELSE}
  1151. If P(Items^[I-1], Hold_EBP) Then Begin { Test each item }
  1152. {$ENDIF}
  1153. {$ENDIF}
  1154. LastThat := Items^[I-1]; { Return item }
  1155. Exit; { Now exit }
  1156. End;
  1157. End;
  1158. LastThat := Nil; { None passed test }
  1159. END;
  1160. FUNCTION TCollection.FirstThat (Test: Pointer): Pointer;
  1161. VAR I: LongInt; P: FuncPtr; {$IFDEF NotFPKPascal} Hold_EBP: Sw_Word; {$ENDIF}
  1162. BEGIN
  1163. {$IFDEF FPKPascal} { FPK pascal compiler }
  1164. ASM
  1165. MOVL (%EBP), %EAX; { Load EBP }
  1166. MOVL %EAX, U_OBJECTS_HOLDEBP; { Store to global }
  1167. END;
  1168. {$ELSE} { Other compilers }
  1169. ASM
  1170. {$IFNDEF CODE_32_BIT} { 16 BIT CODE }
  1171. MOV AX, [BP]; { Load AX from BP }
  1172. {$IFDEF Windows}
  1173. AND AL, 0FEH; { Windows make even }
  1174. {$ENDIF}
  1175. MOV Hold_EBP, AX; { Hold value }
  1176. {$ELSE} { 32 BIT CODE }
  1177. MOV EAX, [EBP]; { Load EAX from EBP }
  1178. MOV Hold_EBP, EAX; { Hold value }
  1179. {$ENDIF}
  1180. END;
  1181. {$ENDIF}
  1182. P := FuncPtr(Test); { Set function ptr }
  1183. For I := 1 To Count Do Begin { Up from first item }
  1184. {$IFDEF FPKPascal}
  1185. {$$$$$$ crashes the compiler
  1186. If P(Items^[I-1], HoldEBP) Then }
  1187. Begin { Test each item }
  1188. {$ELSE}
  1189. {$IFDEF VirtualPascal}
  1190. If P(Items^[I-1]) Then Begin { Test each item }
  1191. {$ELSE}
  1192. If P(Items^[I-1], Hold_EBP) Then Begin { Test each item }
  1193. {$ENDIF}
  1194. {$ENDIF}
  1195. FirstThat := Items^[I-1]; { Return item }
  1196. Exit; { Now exit }
  1197. End;
  1198. End;
  1199. FirstThat := Nil; { None passed test }
  1200. END;
  1201. { ******************************* REMARK ****************************** }
  1202. { Bug fix of TCollection.Pack from the original code which was: }
  1203. { While (I<Count) Do - Yes but who forget to initialize variable I }
  1204. { If count is equal to zero this was going to crash big time and you }
  1205. { must re-adjust the count value - Basically it was stuffed!!! }
  1206. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  1207. PROCEDURE TCollection.Pack;
  1208. VAR I, J: Sw_Integer;
  1209. BEGIN
  1210. If (Count>0) Then Begin { Count is positive }
  1211. I := 0; { Initialize dest }
  1212. For J := 1 To Count Do Begin { For each item }
  1213. If (Items^[J]<>Nil) Then Begin { Entry is non nil }
  1214. Items^[I] := Items^[J]; { Transfer item }
  1215. Inc(I); { Advance dest }
  1216. End;
  1217. End;
  1218. Count := I; { Adjust count }
  1219. End;
  1220. END;
  1221. PROCEDURE TCollection.FreeAll;
  1222. VAR I: Sw_Integer;
  1223. BEGIN
  1224. For I := 0 To Count-1 Do FreeItem(At(I)); { Release each item }
  1225. Count := 0; { Clear item count }
  1226. END;
  1227. PROCEDURE TCollection.DeleteAll;
  1228. BEGIN
  1229. Count := 0; { Clear item count }
  1230. END;
  1231. PROCEDURE TCollection.Free (Item: Pointer);
  1232. BEGIN
  1233. Delete(Item); { Delete from list }
  1234. FreeItem(Item); { Free the item }
  1235. END;
  1236. PROCEDURE TCollection.Insert (Item: Pointer);
  1237. BEGIN
  1238. AtInsert(Count, Item); { Insert item }
  1239. END;
  1240. PROCEDURE TCollection.Delete (Item: Pointer);
  1241. BEGIN
  1242. AtDelete(IndexOf(Item)); { Delete from list }
  1243. END;
  1244. PROCEDURE TCollection.AtFree (Index: Sw_Integer);
  1245. VAR Item: Pointer;
  1246. BEGIN
  1247. Item := At(Index); { Retreive item ptr }
  1248. AtDelete(Index); { Delete item }
  1249. FreeItem(Item); { Free the item }
  1250. END;
  1251. PROCEDURE TCollection.FreeItem (Item: Pointer);
  1252. VAR P: PObject;
  1253. BEGIN
  1254. P := PObject(Item); { Convert pointer }
  1255. If (P<>Nil) Then Dispose(P, Done); { Dispose of object }
  1256. END;
  1257. PROCEDURE TCollection.AtDelete (Index: Sw_Integer);
  1258. BEGIN
  1259. If (Index >= 0) AND (Index < Count) Then Begin { Valid index }
  1260. Dec(Count); { One less item }
  1261. If (Count>Index) Then Move(Items^[Index+1],
  1262. Items^[Index], (Count-Index)*Sizeof(Pointer)); { Shuffle items down }
  1263. End Else Error(coIndexError, Index); { Index error }
  1264. END;
  1265. PROCEDURE TCollection.ForEach (Action: Pointer);
  1266. VAR I: LongInt; P: ProcPtr; {$IFDEF NotFPKPascal} Hold_EBP: Sw_Word; {$ENDIF}
  1267. BEGIN
  1268. {$IFDEF FPKPascal} { FPK pascal compiler }
  1269. ASM
  1270. MOVL (%EBP), %EAX; { Load EBP }
  1271. MOVL %EAX, U_OBJECTS_HOLDEBP; { Store to global }
  1272. END;
  1273. {$ELSE} { Other compilers }
  1274. ASM
  1275. {$IFNDEF CODE_32_BIT} { 16 BIT CODE }
  1276. MOV AX, [BP];
  1277. {$IFDEF WINDOWS}
  1278. AND AL, 0FEH; { Windows make even }
  1279. {$ENDIF}
  1280. MOV Hold_EBP, AX; { Hold value }
  1281. {$ELSE} { 32 BIT CODE }
  1282. MOV EAX, [EBP]; { Load EAX from EBP }
  1283. MOV Hold_EBP, EAX; { Hold value }
  1284. {$ENDIF}
  1285. END;
  1286. {$ENDIF}
  1287. P := ProcPtr(Action); { Set procedure ptr }
  1288. For I := 1 To Count Do { Up from first item }
  1289. {$IFDEF FPKPascal}
  1290. P(Items^[I-1], HoldEBP); { Call with each item }
  1291. {$ELSE}
  1292. {$IFDEF VirtualPascal}
  1293. P(Items^[I-1]); { Call with each item }
  1294. {$ELSE}
  1295. P(Items^[I-1], Hold_EBP); { Call with each item }
  1296. {$ENDIF}
  1297. {$ENDIF}
  1298. END;
  1299. { ******************************* REMARK ****************************** }
  1300. { Bug fix of TCollection.SetLimit from the original code which was: }
  1301. { getmem(p,alimit*sizeof(pointer)); <- This can fail OR ALimit=0 }
  1302. { move(items^,p^,count*sizeof(Pointer)); <- This would now crash! }
  1303. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  1304. PROCEDURE TCollection.SetLimit (ALimit: Sw_Integer);
  1305. VAR AItems: PItemList;
  1306. BEGIN
  1307. If (ALimit < Count) Then ALimit := Count; { Stop underflow }
  1308. If (ALimit > MaxCollectionSize) Then
  1309. ALimit := MaxCollectionSize; { Stop overflow }
  1310. If (ALimit <> Limit) Then Begin { Limits differ }
  1311. If (ALimit = 0) Then AItems := Nil Else { Alimit=0 nil entry }
  1312. GetMem(AItems, ALimit * SizeOf(Pointer)); { Allocate memory }
  1313. If (AItems<>Nil) OR (ALimit=0) Then Begin { Check success }
  1314. If (AItems <>Nil) AND (Items <> Nil) Then { Check both valid }
  1315. Move(Items^, AItems^, Count*SizeOf(Pointer));{ Move existing items }
  1316. If (Limit <> 0) AND (Items <> Nil) Then { Check old allocation }
  1317. FreeMem(Items, Limit * SizeOf(Pointer)); { Release memory }
  1318. Items := AItems; { Update items }
  1319. Limit := ALimit; { Set limits }
  1320. End;
  1321. End;
  1322. END;
  1323. PROCEDURE TCollection.Error (Code, Info: Integer);
  1324. BEGIN
  1325. RunError(212 - Code); { Run error }
  1326. END;
  1327. PROCEDURE TCollection.AtPut (Index: Sw_Integer; Item: Pointer);
  1328. BEGIN
  1329. If (Index >= 0) AND (Index < Count) Then { Index valid }
  1330. Items^[Index] := Item { Put item in index }
  1331. Else Error(coIndexError, Index); { Index error }
  1332. END;
  1333. { ******************************* REMARK ****************************** }
  1334. { Bug fix of TCollection.AtInsert from the original code which was: }
  1335. { original remark: copy old items, count is tested by move }
  1336. { Move(Items^[Index], Items^[Index+1],(Count-Index)*Sizeof(Pointer)); }
  1337. { This does not work you must work from the back down!!!! }
  1338. { ****************************** END REMARK *** Leon de Boer, 10May96 * }
  1339. PROCEDURE TCollection.AtInsert (Index: Sw_Integer; Item: Pointer);
  1340. VAR I: Sw_Integer;
  1341. BEGIN
  1342. If (Index >= 0) AND (Index <= Count) Then Begin { Valid index }
  1343. If (Count=Limit) Then SetLimit(Limit+Delta); { Expand size if able }
  1344. If (Limit>Count) Then Begin
  1345. If (Index < Count) Then Begin { Not last item }
  1346. For I := Count DownTo Index Do { Start from back }
  1347. Items^[I] := Items^[I-1]; { Move each item }
  1348. End;
  1349. Items^[Index] := Item; { Put item in list }
  1350. Inc(Count); { Inc count }
  1351. End Else Error(coOverflow, Index); { Expand failed }
  1352. End Else Error(coIndexError, Index); { Index error }
  1353. END;
  1354. PROCEDURE TCollection.Store (Var S: TStream);
  1355. PROCEDURE DoPutItem (P: Pointer); FAR;
  1356. BEGIN
  1357. PutItem(S, P); { Put item on stream }
  1358. END;
  1359. BEGIN
  1360. S.Write(Count, SizeOf(Count)); { Write count }
  1361. S.Write(Limit, SizeOf(Limit)); { Write limit }
  1362. S.Write(Delta, SizeOf(Delta)); { Write delta }
  1363. ForEach(@DoPutItem); { Each item to stream }
  1364. END;
  1365. PROCEDURE TCollection.PutItem (Var S: TStream; Item: Pointer);
  1366. BEGIN
  1367. S.Put(Item); { Put item on stream }
  1368. END;
  1369. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1370. {Þ TSortedCollection OBJECT METHODS Ý}
  1371. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1372. CONSTRUCTOR TSortedCollection.Init (ALimit, ADelta: Sw_Integer);
  1373. BEGIN
  1374. Inherited Init(ALimit, ADelta); { Call ancestor }
  1375. Duplicates := False; { Clear flag }
  1376. END;
  1377. CONSTRUCTOR TSortedCollection.Load (Var S: TStream);
  1378. BEGIN
  1379. Inherited Load(S); { Call ancestor }
  1380. S.Read(Duplicates, SizeOf(Duplicates)); { Read duplicate flag }
  1381. END;
  1382. FUNCTION TSortedCollection.KeyOf (Item: Pointer): Pointer;
  1383. BEGIN
  1384. KeyOf := Item; { Return item }
  1385. END;
  1386. FUNCTION TSortedCollection.IndexOf (Item: Pointer): Sw_Integer;
  1387. VAR I: Sw_Integer;
  1388. BEGIN
  1389. IndexOf := -1; { Preset result }
  1390. If Search(KeyOf(Item), I) Then Begin { Search for item }
  1391. If Duplicates Then { Duplicates allowed }
  1392. While (I < Count) AND (Item <> Items^[I]) Do
  1393. Inc(I); { Count duplicates }
  1394. If (I < Count) Then IndexOf := I; { Return result }
  1395. End;
  1396. END;
  1397. FUNCTION TSortedCollection.Compare (Key1, Key2: Pointer): Sw_Integer;
  1398. BEGIN
  1399. Abstract; { Abstract method }
  1400. END;
  1401. FUNCTION TSortedCollection.Search (Key: Pointer; Var Index: Sw_Integer): Boolean;
  1402. VAR L, H, I, C: Sw_Integer;
  1403. BEGIN
  1404. Search := False; { Preset failure }
  1405. L := 0; { Start count }
  1406. H := Count - 1; { End count }
  1407. While (L <= H) Do Begin
  1408. I := (L + H) SHR 1; { Mid point }
  1409. C := Compare(KeyOf(Items^[I]), Key); { Compare with key }
  1410. If (C < 0) Then L := I + 1 Else Begin { Item to left }
  1411. H := I - 1; { Item to right }
  1412. If C = 0 Then Begin { Item match found }
  1413. Search := True; { Result true }
  1414. If NOT Duplicates Then L := I; { Force kick out }
  1415. End;
  1416. End;
  1417. End;
  1418. Index := L; { Return result }
  1419. END;
  1420. PROCEDURE TSortedCollection.Insert (Item: Pointer);
  1421. VAR I: Sw_Integer;
  1422. BEGIN
  1423. If NOT Search(KeyOf(Item), I) OR Duplicates Then { Item valid }
  1424. AtInsert(I, Item); { Insert the item }
  1425. END;
  1426. PROCEDURE TSortedCollection.Store (Var S: TStream);
  1427. BEGIN
  1428. TCollection.Store(S); { Call ancestor }
  1429. S.Write(Duplicates, SizeOf(Duplicates)); { Write duplicate flag }
  1430. END;
  1431. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1432. {Þ TStringCollection OBJECT METHODS Ý}
  1433. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1434. FUNCTION TStringCollection.GetItem (Var S: TStream): Pointer;
  1435. BEGIN
  1436. GetItem := S.ReadStr; { Get new item }
  1437. END;
  1438. FUNCTION TStringCollection.Compare (Key1, Key2: Pointer): Sw_Integer;
  1439. VAR I, J: Integer; P1, P2: PString;
  1440. BEGIN
  1441. P1 := PString(Key1); { String 1 pointer }
  1442. P2 := PString(Key2); { String 2 pointer }
  1443. If (Length(P1^)<Length(P2^)) Then J := Length(P1^)
  1444. Else J := Length(P2^); { Shortest length }
  1445. I := 1; { First character }
  1446. While (I<J) AND (P1^[I]=P2^[I]) Do Inc(I); { Scan till fail }
  1447. If (P1^[I]=P2^[I]) Then Compare := 0 Else { Strings matched }
  1448. If (P1^[I]<P2^[I]) Then Compare := -1 Else { String1 < String2 }
  1449. Compare := 1; { String1 > String2 }
  1450. END;
  1451. PROCEDURE TStringCollection.FreeItem (Item: Pointer);
  1452. BEGIN
  1453. DisposeStr(Item); { Dispose item }
  1454. END;
  1455. PROCEDURE TStringCollection.PutItem (Var S: TStream; Item: Pointer);
  1456. BEGIN
  1457. S.WriteStr(Item); { Write string }
  1458. END;
  1459. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1460. {Þ TUnSortedStrCollection OBJECT METHODS Ý}
  1461. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1462. PROCEDURE TUnSortedStrCollection.Insert (Item: Pointer);
  1463. BEGIN
  1464. AtInsert(Count, Item); { NO sorting insert }
  1465. END;
  1466. FUNCTION TStream.Get: PObject;
  1467. BEGIN
  1468. END;
  1469. PROCEDURE TStream.Put (P: PObject);
  1470. BEGIN
  1471. END;
  1472. {***************************************************************************}
  1473. { INTERFACE ROUTINES }
  1474. {***************************************************************************}
  1475. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1476. {Þ DYNAMIC STRING INTERFACE ROUTINES Ý}
  1477. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1478. FUNCTION NewStr (Const S: String): PString;
  1479. VAR P: PString;
  1480. BEGIN
  1481. If (S = '') Then P := Nil Else Begin { Return nil }
  1482. GetMem(P, Length(S) + 1); { Allocate memory }
  1483. If (P<>Nil) Then P^ := S; { Hold string }
  1484. End;
  1485. NewStr := P; { Return result }
  1486. END;
  1487. PROCEDURE DisposeStr (P: PString);
  1488. BEGIN
  1489. If (P <> Nil) Then FreeMem(P, Length(P^) + 1); { Release memory }
  1490. END;
  1491. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1492. {Þ STREAM INTERFACE ROUTINES Ý}
  1493. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1494. PROCEDURE Abstract;
  1495. BEGIN
  1496. RunError(211); { Abstract error }
  1497. END;
  1498. PROCEDURE RegisterError;
  1499. BEGIN
  1500. RunError(212); { Register error }
  1501. END;
  1502. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1503. {Þ NEW FREE VISION STREAM ROUTINES Ý}
  1504. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1505. FUNCTION CreateStream (Strategy: Word; ReqSize: LongInt): PStream;
  1506. VAR Stream: PStream;
  1507. BEGIN
  1508. Stream := Nil; { Preset failure }
  1509. While (Strategy <> 0) AND (Stream = Nil) Do Begin
  1510. If (Strategy AND sa_XMSFirst <> 0) Then Begin { ** XMS STREAM ** }
  1511. End Else
  1512. If (Strategy AND sa_EMSFirst <> 0) Then Begin { ** EMS STREAM ** }
  1513. End Else
  1514. If (Strategy AND sa_RamFirst <> 0) Then Begin { ** RAM STREAM ** }
  1515. End Else
  1516. If (Strategy AND sa_DiskFirst <> 0) Then Begin { ** DISK STREAM ** }
  1517. End;
  1518. If (Stream<>Nil) AND (Stream^.Status <> stOk) { Stream in error }
  1519. Then Begin
  1520. Dispose(Stream, Done); { Dispose stream }
  1521. Stream := Nil; { Clear pointer }
  1522. End;
  1523. Strategy := Strategy SHL 4; { Next strategy mask }
  1524. End;
  1525. CreateStream := Stream; { Return stream result }
  1526. END;
  1527. {ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
  1528. {Þ NEW FREE VISION DOS FILE ROUTINES Ý}
  1529. {ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
  1530. {***************************************************************************}
  1531. { DosFileOpen -> Platforms DOS/DPMI/WIN/OS2 - Checked 16May96 LdB }
  1532. {***************************************************************************}
  1533. FUNCTION DosFileOpen (Var FileName: AsciiZ; Mode: Word): Word;
  1534. {$IFDEF NotOS2} { DOS/DPMI/WINDOWS }
  1535. {$IFDEF FPKPascal} { FPK Pascal compiler }
  1536. {$IFDEF GO32V2}
  1537. var regs : trealregs;
  1538. BEGIN
  1539. syscopytodos(longint(@FileName),256);
  1540. regs.realedx:=tb mod 16;
  1541. regs.realds:=tb div 16;
  1542. regs.realeax := Mode;
  1543. regs.realecx:=0;
  1544. sysrealintr($21,regs);
  1545. if (regs.realflags and 1) <> 0 then
  1546. begin
  1547. InOutRes:=lo(regs.realeax);
  1548. DosFileOpen:=-1;
  1549. exit;
  1550. end else
  1551. DosFileOpen:=regs.realeax;
  1552. END;
  1553. {$ELSE not GO32V2}
  1554. BEGIN
  1555. ASM
  1556. XOR %AX, %AX; { Clear error }
  1557. MOVW %AX, U_OBJECTS_DOSSTREAMERROR;
  1558. MOVL Filename, %EDX; { Filename to open }
  1559. XOR %CX, %CX;
  1560. MOVW Mode, %AX; { Mode to open file }
  1561. PUSHL %EBP;
  1562. INT $0x21; { Open/create the file }
  1563. POPL %EBP;
  1564. JNC EXIT1;
  1565. MOV %AX, U_OBJECTS_DOSSTREAMERROR; { Hold error }
  1566. XOR %AX, %AX; { Open failed }
  1567. EXIT1:
  1568. MOV %AX, U_OBJECTS_TRANSFERHANDLE; { Hold opened handle }
  1569. END;
  1570. DosFileOpen := TransferHandle; { Return handle }
  1571. END;
  1572. {$ENDIF GO32V2}
  1573. {$ELSE} { Other compilers }
  1574. ASSEMBLER;
  1575. ASM
  1576. XOR AX, AX; { Dos error cleared }
  1577. MOV DosStreamError, AX;
  1578. MOV AX, Mode; { Mode to open file }
  1579. PUSH DS;
  1580. LDS DX, FileName; { Filename to open }
  1581. XOR CX, CX;
  1582. INT $21; { Open/create file }
  1583. POP DS;
  1584. JNC @@Exit1; { Check for error }
  1585. MOV DosStreamError, AX;
  1586. XOR AX, AX; { Open fail return 0 }
  1587. @@Exit1:
  1588. END;
  1589. {$ENDIF}
  1590. {$ELSE} { OS2 CODE }
  1591. {$IFNDEF FPK}
  1592. VAR Attr, OpenFlags, OpenMode: Word; Success, Handle, ActionTaken: Sw_Word;
  1593. BEGIN
  1594. Case Mode Of
  1595. stCreate: Begin { Create file }
  1596. Attr := $20; { Archive file }
  1597. OpenFlags := 18; { Open flags }
  1598. OpenMode := FmInOut; { Input/output file }
  1599. End;
  1600. stOpenRead: Begin { Open file for read }
  1601. Attr := $0; { Any attributes }
  1602. OpenFlags := 1; { Open flags }
  1603. OpenMode := FmInput; { Input file }
  1604. End;
  1605. stOpenWrite: Begin { Open file for write }
  1606. Attr := $0; { Any attributes }
  1607. OpenFlags := 1; { Open flags }
  1608. OpenMode := FmOutput; { Output file }
  1609. End;
  1610. stOpen: Begin { Open file read/write }
  1611. Attr := $0; { Any attributes }
  1612. OpenFlags := 1; { Open flags }
  1613. OpenMode := FmInOut; { Input/output file }
  1614. End;
  1615. End;
  1616. {$IFDEF Speed} { Speed pascal differs }
  1617. DosStreamError := DosOpen(CString(FileName), Handle,
  1618. {$ELSE} { Other OS2 compilers }
  1619. DosStreamError := DosOpen(@FileName[0], Handle,
  1620. {$ENDIF}
  1621. ActionTaken, 0, Attr, OpenFlags, OpenMode, Nil); { Open the file }
  1622. If (DosStreamError=0) Then DosFileOpen := Handle { Successful open }
  1623. Else DosFileOpen := 0; { Fail so return zero }
  1624. END;
  1625. {$ELSE FPK}
  1626. BEGIN
  1627. ASM
  1628. XOR %AX, %AX; { Clear error }
  1629. MOVW %AX, U_OBJECTS_DOSSTREAMERROR;
  1630. MOVL Filename, %EDX; { Filename to open }
  1631. XOR %CX, %CX;
  1632. MOVW Mode, %AX; { Mode to open file }
  1633. CALL ___SYSCALL; { Open/create the file }
  1634. JNC EXIT1;
  1635. MOV %AX, U_OBJECTS_DOSSTREAMERROR; { Hold error }
  1636. XOR %AX, %AX; { Open failed }
  1637. EXIT1:
  1638. MOV %AX, U_OBJECTS_TRANSFERHANDLE; { Hold opened handle }
  1639. END;
  1640. DosFileOpen := TransferHandle; { Return handle }
  1641. END;
  1642. {$ENDIF FPK}
  1643. {$ENDIF}
  1644. {***************************************************************************}
  1645. { DosRead -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB }
  1646. {***************************************************************************}
  1647. FUNCTION DosRead (Handle: Word; Var BufferArea; BufferLength: Sw_Word;
  1648. Var BytesMoved: Sw_Word): Word;
  1649. {$IFDEF FPKPascal} { FPK pascal compiler }
  1650. {$IFDEF GO32V2}
  1651. BEGIN
  1652. BytesMoved:=system.dosread(Handle,longint(@BufferArea),BufferLength);
  1653. DosRead:=InOutRes;
  1654. End;
  1655. {$ELSE not GO32V2}
  1656. {$IFNDEF OS2}
  1657. BEGIN
  1658. ASM
  1659. MOVL BufferArea, %EDX; { Buffer for data }
  1660. MOVL BufferLength, %CX; { Bytes to read }
  1661. MOVB $0x3F, %AH;
  1662. MOVW Handle, %BX; { Load file handle }
  1663. PUSHL %EBP;
  1664. INT $0x21; { Read from file }
  1665. POPL %EBP;
  1666. JC EXIT2; { Check for error }
  1667. MOVL BytesMoved, %EDI;
  1668. MOVZWL %AX, %EAX;
  1669. MOVL %EAX, (%EDI); { Update bytes moved }
  1670. XOR %EAX, %EAX; { Clear register }
  1671. EXIT2:
  1672. MOV %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1673. END;
  1674. DosRead := DosStreamError; { Return any error }
  1675. END;
  1676. {$ELSE OS2}
  1677. BEGIN
  1678. ASM
  1679. MOVL BufferArea, %EDX; { Buffer for data }
  1680. MOVL BufferLength, %CX; { Bytes to read }
  1681. MOVB $0x3F, %AH;
  1682. MOVW Handle, %BX; { Load file handle }
  1683. CALL ___SYSCALL; { Read from file }
  1684. JC EXIT2; { Check for error }
  1685. MOVL BytesMoved, %EDI;
  1686. MOVZWL %AX, %EAX;
  1687. MOVL %EAX, (%EDI); { Update bytes moved }
  1688. XOR %EAX, %EAX; { Clear register }
  1689. EXIT2:
  1690. MOV %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1691. END;
  1692. DosRead := DosStreamError; { Return any error }
  1693. END;
  1694. {$ENDIF OS2}
  1695. {$EndIf GO32V2}
  1696. {$ELSE} { Other compilers }
  1697. ASSEMBLER;
  1698. ASM
  1699. PUSH DS;
  1700. LDS DX, BufferArea; { Data dest buffer }
  1701. MOV CX, BufferLength;
  1702. MOV BX, Handle; { Load file handle }
  1703. MOV AH, $0x3F;
  1704. INT $0x21; { Read from file }
  1705. POP DS;
  1706. JC @@Exit2; { Check for error }
  1707. LES DI, BytesMoved;
  1708. MOV ES:[DI], AX; { Update bytes moved }
  1709. XOR AX, AX;
  1710. @@Exit2:
  1711. MOV DosStreamError, AX; { DOS error returned }
  1712. END;
  1713. {$ENDIF}
  1714. {***************************************************************************}
  1715. { DosWrite -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB }
  1716. {***************************************************************************}
  1717. FUNCTION DosWrite (Handle: Word; Var BufferArea; BufferLength: Sw_Word;
  1718. Var BytesMoved: Sw_Word): Word;
  1719. {$IFDEF FPKPascal} { FPK pascal compiler }
  1720. {$IFDEF GO32V2}
  1721. BEGIN
  1722. system.doswrite(Handle,longint(@BufferArea),BufferLength);
  1723. BytesMoved:=BufferLength;
  1724. DosWrite:=InOutRes;
  1725. End;
  1726. {$ELSE not GO32V2}
  1727. BEGIN
  1728. ASM
  1729. MOVL BufferArea, %EDX; { Buffer with data }
  1730. MOVL BufferLength, %CX; { Bytes to write }
  1731. MOVB $0x40, %AH;
  1732. MOVW Handle, %BX; { Load file handle }
  1733. PUSHL %EBP;
  1734. INT $0x21; { Write to file }
  1735. POPL %EBP;
  1736. JC EXIT3; { Check for error }
  1737. MOVL BytesMoved, %EDI;
  1738. MOVZWL %AX, %EAX;
  1739. MOVL %EAX, (%EDI); { Update bytes moved }
  1740. XOR %EAX, %EAX;
  1741. EXIT3:
  1742. MOV %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1743. END;
  1744. DosWrite := DosStreamError; { Return any error }
  1745. END;
  1746. {$ENDIF GO32V2}
  1747. {$ELSE} { Other compilers }
  1748. ASSEMBLER;
  1749. ASM
  1750. PUSH DS;
  1751. LDS DX, BufferArea; { Data source buffer }
  1752. MOV CX, BufferLength;
  1753. MOV BX, Handle; { Load file handle }
  1754. MOV AH, $40;
  1755. INT $21; { Write to file }
  1756. POP DS;
  1757. JC @@Exit3; { Check for error }
  1758. LES DI, BytesMoved;
  1759. MOV ES:[DI], AX; { Update bytes moved }
  1760. XOR AX, AX;
  1761. @@Exit3:
  1762. MOV DosStreamError, AX; { DOS error returned }
  1763. END;
  1764. {$ENDIF}
  1765. {***************************************************************************}
  1766. { DosSetFilePtr -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB }
  1767. {***************************************************************************}
  1768. FUNCTION DosSetFilePtr (Handle: Word; Pos: LongInt; MoveType: Word;
  1769. VAR NewPos: LongInt): Word;
  1770. {$IFDEF FPKPascal} { FPK pascal compiler }
  1771. {$IFNDEF OS2}
  1772. BEGIN
  1773. ASM
  1774. MOVW MoveType, %AX; { Load move type }
  1775. MOVB $0x42, %AH;
  1776. MOVW POS, %DX; { Load file position }
  1777. MOVL POS, %ECX;
  1778. SHRL $16,%ECX;
  1779. MOVW Handle, %BX; { Load file handle }
  1780. PUSHL %EBP;
  1781. INT $0x21; { Position the file }
  1782. POPL %EBP;
  1783. JC EXIT4;
  1784. MOVL NewPos, %EDI; { New position address }
  1785. MOVW %AX, %BX;
  1786. MOVW %DX, %AX;
  1787. SHLL $0x10, %EAX; { Roll to high part }
  1788. MOVW %BX, %AX;
  1789. MOVL %EAX, (%EDI); { Update new position }
  1790. XOR %EAX, %EAX;
  1791. EXIT4:
  1792. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1793. END;
  1794. DosSetFilePtr := DosStreamError; { Return any error }
  1795. END;
  1796. {$ELSE OS2}
  1797. BEGIN
  1798. ASM
  1799. MOVW MoveType, %AX; { Load move type }
  1800. MOVB $0x42, %AH;
  1801. MOVW POS, %DX; { Load file position }
  1802. MOVL POS, %ECX;
  1803. SHRL $16,%ECX;
  1804. MOVW Handle, %BX; { Load file handle }
  1805. CALL ___SYSCALL; { Position the file }
  1806. JC EXIT4;
  1807. MOVL NewPos, %EDI; { New position address }
  1808. MOVW %AX, %BX;
  1809. MOVW %DX, %AX;
  1810. SHLL $0x10, %EAX; { Roll to high part }
  1811. MOVW %BX, %AX;
  1812. MOVL %EAX, (%EDI); { Update new position }
  1813. XOR %EAX, %EAX;
  1814. EXIT4:
  1815. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1816. END;
  1817. DosSetFilePtr := DosStreamError; { Return any error }
  1818. END;
  1819. {$ENDIF OS2}
  1820. {$ELSE} { Other compilers }
  1821. ASSEMBLER;
  1822. ASM
  1823. MOV AX, MoveType; { Load move type }
  1824. MOV AH, $42;
  1825. MOV DX, Pos.Word[0]; { Load file position }
  1826. MOV CX, Pos.Word[2];
  1827. MOV BX, Handle; { Load file handle }
  1828. INT $21; { Position the file }
  1829. JC @@Exit4;
  1830. LES DI, NewPos; { New position address }
  1831. MOV ES:[DI], AX;
  1832. MOV ES:[DI+2], DX; { Update new position }
  1833. XOR AX, AX;
  1834. @@Exit4:
  1835. MOV DosStreamError, AX; { DOS error returned }
  1836. END;
  1837. {$ENDIF}
  1838. {***************************************************************************}
  1839. { DosClose -> Platforms DOS/DPMI/WIN - Checked 16May96 LdB }
  1840. {***************************************************************************}
  1841. PROCEDURE DosClose (Handle: Word);
  1842. {$IFDEF FPKPascal} { FPK pascal compiler }
  1843. {$IFNDEF OS2}
  1844. BEGIN
  1845. ASM
  1846. XOR %AX, %AX;
  1847. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error cleared }
  1848. MOVB $0x3E, %AH;
  1849. MOVW Handle, %BX; { DOS file handle }
  1850. PUSHL %EBP;
  1851. INT $0x21; { Close the file }
  1852. POPL %EBP;
  1853. JNC EXIT5;
  1854. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1855. EXIT5:
  1856. END;
  1857. END;
  1858. {$ELSE OS2}
  1859. BEGIN
  1860. ASM
  1861. XOR %AX, %AX;
  1862. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error cleared }
  1863. MOVB $0x3E, %AH;
  1864. MOVW Handle, %BX; { DOS file handle }
  1865. CALL ___SYSCALL; { Close the file }
  1866. JNC EXIT5;
  1867. MOVW %AX, U_OBJECTS_DOSSTREAMERROR; { DOS error returned }
  1868. EXIT5:
  1869. END;
  1870. END;
  1871. {$ENDIF OS2}
  1872. {$ELSE} { Other compilers }
  1873. ASSEMBLER;
  1874. ASM
  1875. XOR AX, AX; { DOS error cleared }
  1876. MOV DosStreamError, AX;
  1877. MOV BX, Handle; { DOS file handle }
  1878. MOV AH, $3E;
  1879. INT $21; { Close the file }
  1880. JNC @@Exit5;
  1881. MOV DosStreamError, AX; { DOS error returned }
  1882. @@Exit5:
  1883. END;
  1884. {$ENDIF}
  1885. END.