sysutils.tex 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1999, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The SYSUTILS unit.}
  22. This chapter describes the \file{sysutils} unit. The \var{sysutils} unit
  23. was largely written by Gertjan Schouten, and completed by michael Van Canneyt.
  24. It aims to be compatible to the Delphi sysutils unit, but in contrast with
  25. the latter, it is designed to work on multiple platforms.
  26. This chapter starts out with a definition of all types and constants
  27. that are defined, followed by a complete explanation of each function.
  28. \section{Constants and types}
  29. The following general-purpose constants are defined:
  30. \begin{verbatim}
  31. const
  32. SecsPerDay = 24 * 60 * 60; // Seconds and milliseconds per day
  33. MSecsPerDay = SecsPerDay * 1000;
  34. DateDelta = 693594; // Days between 1/1/0001 and 12/31/1899
  35. Eoln = #10;
  36. \end{verbatim}
  37. The following types are used frequently in date and time functions.
  38. They are the same on all platforms.
  39. \begin{verbatim}
  40. type
  41. TSystemTime = record
  42. Year, Month, Day: word;
  43. Hour, Minute, Second, MilliSecond: word;
  44. end ;
  45. TDateTime = double;
  46. TTimeStamp = record
  47. Time: integer; { Number of milliseconds since midnight }
  48. Date: integer; { One plus number of days since 1/1/0001 }
  49. end ;
  50. \end{verbatim}
  51. The following type is used in the \seef{FindFirst},\seef{FindNext}
  52. and \seepl{FindClose}{FindCloseSys} functions. The \var{win32} version differs from
  53. the other versions. If code is to be portable, that part shouldn't
  54. be used.
  55. \begin{verbatim}
  56. Type
  57. THandle = Longint;
  58. TSearchRec = Record
  59. Time,Size, Attr : Longint;
  60. Name : TFileName;
  61. ExcludeAttr : Longint;
  62. FindHandle : THandle;
  63. {$ifdef Win32}
  64. FindData : TWin32FindData;
  65. {$endif}
  66. end;
  67. \end{verbatim}
  68. The following constants are file-attributes that need to be matched in the
  69. findfirst call.
  70. \begin{verbatim}
  71. Const
  72. faReadOnly = $00000001;
  73. faHidden = $00000002;
  74. faSysFile = $00000004;
  75. faVolumeId = $00000008;
  76. faDirectory = $00000010;
  77. faArchive = $00000020;
  78. faAnyFile = $0000003f;
  79. \end{verbatim}
  80. The following constants can be used in the \seef{FileOpen} call.
  81. \begin{verbatim}
  82. Const
  83. fmOpenRead = $0000;
  84. fmOpenWrite = $0001;
  85. fmOpenReadWrite = $0002;
  86. \end{verbatim}
  87. The following constants can be used in the \seef{FileSeek} call.
  88. \begin{verbatim}
  89. Const
  90. fsFromBeginning = 0;
  91. fsFromCurrent = 1;
  92. fsFromEnd = 2;
  93. \end{verbatim}
  94. The following variables are used in the case translation routines.
  95. \begin{verbatim}
  96. type
  97. TCaseTranslationTable = array[0..255] of char;
  98. var
  99. UpperCaseTable: TCaseTranslationTable;
  100. LowerCaseTable: TCaseTranslationTable;
  101. \end{verbatim}
  102. The initialization code of the \file{sysutils} unit fills these
  103. tables with the appropriate values. For the win32 and go32v2
  104. versions, this information is obtained from the operating system.
  105. The following constants control the formatting of dates.
  106. For the Win32 version of the \file{sysutils} unit, these
  107. constants are set according to the internationalization
  108. settings of Windows by the initialization code of the unit.
  109. \begin{verbatim}
  110. Const
  111. DateSeparator: char = '-';
  112. ShortDateFormat: string = 'd/m/y';
  113. LongDateFormat: string = 'dd" "mmmm" "yyyy';
  114. ShortMonthNames: array[1..12] of string[128] =
  115. ('Jan','Feb','Mar','Apr','May','Jun',
  116. 'Jul','Aug','Sep','Oct','Nov','Dec');
  117. LongMonthNames: array[1..12] of string[128] =
  118. ('January','February','March','April',
  119. 'May','June','July','August',
  120. 'September','October','November','December');
  121. ShortDayNames: array[1..7] of string[128] =
  122. ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  123. LongDayNames: array[1..7] of string[128] =
  124. ('Sunday','Monday','Tuesday','Wednesday',
  125. 'Thursday','Friday','Saturday');
  126. \end{verbatim}
  127. The following constants control the formatting of times.
  128. For the Win32 version of the \file{sysutils} unit, these
  129. constants are set according to the internationalization
  130. settings of Windows by the initialization code of the unit.
  131. \begin{verbatim}
  132. Const
  133. ShortTimeFormat: string = 'hh:nn';
  134. LongTimeFormat: string = 'hh:nn:ss';
  135. TimeSeparator: char = ':';
  136. TimeAMString: string[7] = 'AM';
  137. TimePMString: string[7] = 'PM';
  138. \end{verbatim}
  139. The following constants control the formatting of currencies
  140. and numbers. For the Win32 version of the \file{sysutils} unit,
  141. these constants are set according to the internationalization
  142. settings of Windows by the initialization code of the unit.
  143. \begin{verbatim}
  144. Const
  145. DecimalSeparator : Char = '.';
  146. ThousandSeparator : Char = ',';
  147. CurrencyDecimals : Byte = 2;
  148. CurrencyString : String[7] = '$';
  149. { Format to use when formatting currency :
  150. 0 = $1 1 = 1$ 2 = $ 1 3 = 1 $
  151. 4 = Currency string replaces decimal indicator.
  152. e.g. 1$50
  153. }
  154. CurrencyFormat : Byte = 1;
  155. { Same as above, only for negative currencies:
  156. 0 = ($1)
  157. 1 = -$1
  158. 2 = $-1
  159. 3 = $1-
  160. 4 = (1$)
  161. 5 = -1$
  162. 6 = 1-$
  163. 7 = 1$-
  164. 8 = -1 $
  165. 9 = -$ 1
  166. 10 = $ 1-
  167. }
  168. NegCurrFormat : Byte = 5;
  169. \end{verbatim}
  170. The following types are used in various string functions.
  171. \begin{verbatim}
  172. type
  173. PString = ^String;
  174. TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
  175. \end{verbatim}
  176. The following constants are used in the file name handling routines. Do not
  177. use a slash of backslash character directly as a path separator; instead
  178. use the \var{OsDirSeparator} character.
  179. \begin{verbatim}
  180. Const
  181. DirSeparators : set of char = ['/','\'];
  182. {$ifdef Linux}
  183. OSDirSeparator = '/';
  184. {$else}
  185. OsDirSeparator = '\';
  186. {$endif}
  187. \end{verbatim}
  188. \section{Date and time functions}
  189. \subsection{Date and time formatting characters}
  190. \label{se:formatchars}
  191. Various date and time formatting routines accept a format string.
  192. to format the date and or time. The following characters can be used
  193. to control the date and time formatting:
  194. \begin{description}
  195. \item[c] : shortdateformat + ' ' + shorttimeformat
  196. \item[d] : day of month
  197. \item[dd] : day of month (leading zero)
  198. \item[ddd] : day of week (abbreviation)
  199. \item[dddd] : day of week (full)
  200. \item[ddddd] : shortdateformat
  201. \item[dddddd] : longdateformat
  202. \item[m] : month
  203. \item[mm] : month (leading zero)
  204. \item[mmm] : month (abbreviation)
  205. \item[mmmm] : month (full)
  206. \item[y] : year (four digits)
  207. \item[yy] : year (two digits)
  208. \item[yyyy] : year (with century)
  209. \item[h] : hour
  210. \item[hh] : hour (leading zero)
  211. \item[n] : minute
  212. \item[nn] : minute (leading zero)
  213. \item[s] : second
  214. \item[ss] : second (leading zero)
  215. \item[t] : shorttimeformat
  216. \item[tt] : longtimeformat
  217. \item[am/pm] : use 12 hour clock and display am and pm accordingly
  218. \item[a/p] : use 12 hour clock and display a and p accordingly
  219. \item[/] : insert date seperator
  220. \item[:] : insert time seperator
  221. \item["xx"] : literal text
  222. \item['xx'] : literal text
  223. \end{description}
  224. \begin{type}{TDateTime}
  225. \Declaration
  226. TDateTime = Double;
  227. \Description
  228. Many functions return or require a \var{TDateTime} type, which contains
  229. a date and time in encoded form. The date and time are converted to a double
  230. as follows:
  231. \end{type}
  232. \begin{function}{Date}
  233. \Declaration
  234. Function Date: TDateTime;
  235. \Description
  236. \var{Date} returns the current date in \var{TDateTime} format.
  237. For more information about the \var{TDateTime} type, see \seetype{TDateTime}.
  238. \Errors
  239. None.
  240. \SeeAlso
  241. \seef{Time},\seef{Now}, \seetype{TDateTime}.
  242. \end{function}
  243. \latex{\lstinputlisting{sysutex/ex1.pp}}
  244. \html{\input{sysutex/ex1.tex}}
  245. \begin{function}{DateTimeToFileDate}
  246. \Declaration
  247. Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
  248. \Description
  249. \var{DateTimeToFileDate} function converts a date/time indication in
  250. \var{TDateTime} format to a filedate function, such as returned for
  251. instance by the \seef{FileAge} function.
  252. \Errors
  253. None.
  254. \SeeAlso
  255. \seef{Time}, \seef{Date}, \seef{FileDateToDateTime},
  256. \seep{DateTimeToSystemTime}, \seef{DateTimeToTimeStamp}
  257. \end{function}
  258. \latex{\lstinputlisting{sysutex/ex2.pp}}
  259. \html{\input{sysutex/ex2.tex}}
  260. \begin{function}{DateTimeToStr}
  261. \Declaration
  262. Function DateTimeToStr(DateTime: TDateTime): string;
  263. \Description
  264. \var{DateTimeToStr} returns a string representation of
  265. \var{DateTime} using the formatting specified in
  266. \var{ShortDateTimeFormat}. It corresponds to a call to
  267. \var{FormatDateTime('c',DateTime)} (see \sees{formatchars}).
  268. \Errors
  269. None.
  270. \SeeAlso
  271. \seef{FormatDateTime}, \seetype{TDateTime}.
  272. \end{function}
  273. \latex{\lstinputlisting{sysutex/ex3.pp}}
  274. \html{\input{sysutex/ex3.tex}}
  275. \begin{procedure}{DateTimeToString}
  276. \Declaration
  277. Procedure DateTimeToString(var Result: string; const FormatStr: string; const DateTime: TDateTime);
  278. \Description
  279. \var{DateTimeToString} returns in \var{Result} a string representation of
  280. \var{DateTime} using the formatting specified in \var{FormatStr}.
  281. for a list of characters that can be used in the \var{FormatStr} formatting
  282. string, see \sees{formatchars}.
  283. \Errors
  284. In case a wrong formatting character is found, an \var{EConvertError} is
  285. raised.
  286. \SeeAlso
  287. \seef{FormatDateTime}, \sees{formatchars}.
  288. \end{procedure}
  289. \latex{\lstinputlisting{sysutex/ex4.pp}}
  290. \html{\input{sysutex/ex4.tex}}
  291. \begin{procedure}{DateTimeToSystemTime}
  292. \Declaration
  293. Procedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);
  294. \Description
  295. \var{DateTimeToSystemTime} converts a date/time pair in \var{DateTime}, with
  296. \var{TDateTime} format to a system time \var{SystemTime}.
  297. \Errors
  298. None.
  299. \SeeAlso
  300. \seef{DateTimeToFileDate}, \seef{SystemTimeToDateTime},
  301. \seef{DateTimeToTimeStamp}
  302. \end{procedure}
  303. \latex{\lstinputlisting{sysutex/ex5.pp}}
  304. \html{\input{sysutex/ex5.tex}}
  305. \begin{function}{DateTimeToTimeStamp}
  306. \Declaration
  307. Function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
  308. \Description
  309. \var{DateTimeToSystemTime} converts a date/time pair in \var{DateTime}, with
  310. \var{TDateTime} format to a \var{TTimeStamp} format.
  311. \Errors
  312. None.
  313. \SeeAlso
  314. \seef{DateTimeToFileDate}, \seef{SystemTimeToDateTime},
  315. \seep{DateTimeToSystemTime}
  316. \end{function}
  317. \latex{\lstinputlisting{sysutex/ex6.pp}}
  318. \html{\input{sysutex/ex6.tex}}
  319. \begin{function}{DateToStr}
  320. \Declaration
  321. Function DateToStr(Date: TDateTime): string;
  322. \Description
  323. \var{DateToStr} converts \var{Date} to a string representation. It uses
  324. \var{ShortDateFormat} as it's formatting string. It is hence completely
  325. equivalent to a \var{FormatDateTime('ddddd', Date)}.
  326. \Errors
  327. None.
  328. \SeeAlso
  329. \seef{TimeToStr}, \seef{DateTimeToStr}, \seef{FormatDateTime},
  330. \seef{StrToDate}
  331. \end{function}
  332. \latex{\lstinputlisting{sysutex/ex7.pp}}
  333. \html{\input{sysutex/ex7.tex}}
  334. \begin{function}{DayOfWeek}
  335. \Declaration
  336. Function DayOfWeek(DateTime: TDateTime): integer;
  337. \Description
  338. \var{DayOfWeek} returns the day of the week from \var{DateTime}.
  339. \var{Sunday} is counted as day 1, \var{Saturday} is counted as
  340. day 7. The result of \var{DayOfWeek} can serve as an index to
  341. the \var{LongDayNames} constant array, to retrieve the name of
  342. the day.
  343. \Errors
  344. None.
  345. \SeeAlso
  346. \seef{Date}, \seef{DateToStr}
  347. \end{function}
  348. \latex{\lstinputlisting{sysutex/ex8.pp}}
  349. \html{\input{sysutex/ex8.tex}}
  350. \begin{procedure}{DecodeDate}
  351. \Declaration
  352. Procedure DecodeDate(Date: TDateTime; var Year, Month, Day: word);
  353. \Description
  354. \var{DecodeDate} decodes the Year, Month and Day stored in \var{Date},
  355. and returns them in the \var{Year}, \var{Month} and \var{Day} variables.
  356. \Errors
  357. None.
  358. \SeeAlso
  359. \seef{EncodeDate}, \seep{DecodeTime}.
  360. \end{procedure}
  361. \latex{\lstinputlisting{sysutex/ex9.pp}}
  362. \html{\input{sysutex/ex9.tex}}
  363. \begin{procedure}{DecodeTime}
  364. \Declaration
  365. Procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
  366. \Description
  367. \var{DecodeDate} decodes the hours, minutes, second and milliseconds stored
  368. in \var{Time}, and returns them in the \var{Hour}, \var{Minute} and
  369. \var{Second} and \var{MilliSecond} variables.
  370. \Errors
  371. None.
  372. \SeeAlso
  373. \seef{EncodeTime}, \seep{DecodeDate}.
  374. \end{procedure}
  375. \latex{\lstinputlisting{sysutex/ex10.pp}}
  376. \html{\input{sysutex/ex10.tex}}
  377. \begin{function}{EncodeDate}
  378. \Declaration
  379. Function EncodeDate(Year, Month, Day :word): TDateTime;
  380. \Description
  381. \var{EncodeDate} encodes the \var{Year}, \var{Month} and \var{Day} variables to
  382. a date in \var{TDateTime} format. It does the opposite of the
  383. \seep{DecodeDate} procedure.
  384. The parameters must lie withing valid ranges (boundaries included):
  385. \begin{description}
  386. \item[Year] must be between 1 and 9999.
  387. \item[Month] must be within the range 1-12.
  388. \item[Day] msut be between 1 and 31.
  389. \end{description}
  390. \Errors
  391. In case one of the parameters is out of it's valid range, 0 is returned.
  392. \SeeAlso
  393. \seef{EncodeTime}, \seep{DecodeDate}.
  394. \end{function}
  395. \latex{\lstinputlisting{sysutex/ex11.pp}}
  396. \html{\input{sysutex/ex11.tex}}
  397. \begin{function}{EncodeTime}
  398. \Declaration
  399. Function EncodeTime(Hour, Minute, Second, MilliSecond:word): TDateTime;
  400. \Description
  401. \var{EncodeTime} encodes the \var{Hour}, \var{Minute}, \var{Second},
  402. \var{MilliSecond} variables to a \var{TDateTime} format result.
  403. It does the opposite of the \seep{DecodeTime} procedure.
  404. The parameters must have a valid range (boundaries included):
  405. \begin{description}
  406. \item[Hour] must be between 0 and 23.
  407. \item[Minute,second] must both be between 0 and 59.
  408. \item[Millisecond] must be between 0 and 999.
  409. \end{description}
  410. \Errors
  411. In case one of the parameters is outside of it's valid range, 0 is returned.
  412. \SeeAlso
  413. \seef{EncodeDate}, \seep{DecodeTime}.
  414. \end{function}
  415. \latex{\lstinputlisting{sysutex/ex12.pp}}
  416. \html{\input{sysutex/ex12.tex}}
  417. \begin{function}{FileDateToDateTime}
  418. \Declaration
  419. Function FileDateToDateTime(Filedate : Longint) : TDateTime;
  420. \Description
  421. \var{FileDateToDateTime} converts the date/time encoded in \var{filedate}
  422. to a \var{TDateTime} encoded form. It can be used to convert date/time values
  423. returned by the \seef{FileAge} or \seef{FindFirst}/\seef{FindNext}
  424. functions to \var{TDateTime} form.
  425. \Errors
  426. None.
  427. \SeeAlso
  428. \seef{DateTimeToFileDate}
  429. \end{function}
  430. \latex{\lstinputlisting{sysutex/ex13.pp}}
  431. \html{\input{sysutex/ex13.tex}}
  432. \begin{function}{FormatDateTime}
  433. \Declaration
  434. Function FormatDateTime(FormatStr: string; DateTime: TDateTime):string;
  435. \Description
  436. \var{FormatDateTime} formats the date and time encoded in \var{DateTime}
  437. according to the formatting given in \var{FormatStr}. The complete list
  438. of formatting characters can be found in \sees{formatchars}.
  439. \Errors
  440. On error (such as an invalid character in the formatting string), and
  441. \var{EConvertError} exception is raised.
  442. \SeeAlso
  443. \seef{DateTimeToStr}, \seef{DateToStr}, \seef{TimeToStr},
  444. \seef{StrToDateTime}
  445. \end{function}
  446. \latex{\lstinputlisting{sysutex/ex14.pp}}
  447. \html{\input{sysutex/ex14.tex}}
  448. \begin{function}{IncMonth}
  449. \Declaration
  450. Function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer): TDateTime;
  451. \Description
  452. \var{IncMonth} increases the month number in \var{DateTime} with
  453. \var{NumberOfMonths}. It wraps the result as to get a month between 1 and
  454. 12, and updates the year accordingly. \var{NumberOfMonths} can be negative,
  455. and can be larger than 12 (in absolute value).
  456. \Errors
  457. None.
  458. \SeeAlso
  459. \seef{Date}, \seef{Time}, \seef{Now}
  460. \end{function}
  461. \latex{\lstinputlisting{sysutex/ex15.pp}}
  462. \html{\input{sysutex/ex15.tex}}
  463. \begin{function}{IsLeapYear}
  464. \Declaration
  465. Function IsLeapYear(Year: Word): boolean;
  466. \Description
  467. \var{IsLeapYear} returns \var{True} if \var{Year} is a leap year,
  468. \var{False} otherwise.
  469. \Errors
  470. None.
  471. \SeeAlso
  472. \seef{IncMonth}, \seef{Date}
  473. \end{function}
  474. \latex{\lstinputlisting{sysutex/ex16.pp}}
  475. \html{\input{sysutex/ex16.tex}}
  476. \begin{function}{MSecsToTimeStamp}
  477. \Declaration
  478. Function MSecsToTimeStamp(MSecs: Comp): TTimeStamp;
  479. \Description
  480. \var{MSecsTiTimeStamp} converts the given number of milliseconds to
  481. a \var{TTimeStamp} date/time notation.
  482. Use \var{TTimeStamp} variables if you need to keep very precise track of
  483. time.
  484. \Errors
  485. None.
  486. \SeeAlso
  487. \seef{TimeStampToMSecs}, \seef{DateTimeToTimeStamp},
  488. \end{function}
  489. \latex{\lstinputlisting{sysutex/ex17.pp}}
  490. \html{\input{sysutex/ex17.tex}}
  491. \begin{function}{Now}
  492. \Declaration
  493. Function Now: TDateTime;
  494. \Description
  495. \var{Now} returns the current date and time. It is equivalent to
  496. \var{Date+Time}.
  497. \Errors
  498. None.
  499. \SeeAlso
  500. \seef{Date}, \seef{Time}
  501. \end{function}
  502. \latex{\lstinputlisting{sysutex/ex18.pp}}
  503. \html{\input{sysutex/ex18.tex}}
  504. \begin{function}{StrToDate}
  505. \Declaration
  506. Function StrToDate(const S: string): TDateTime;
  507. \Description
  508. \var{StrToDate} converts the string \var{S} to a \var{TDateTime} date
  509. value. The Date must consist of 1 to three digits, separated by the
  510. \var{DateSeparator} character. If two numbers are given, they
  511. are supposed to form the day and month of the current year. If only
  512. one number is given, it is supposed to represent the day of the
  513. current month. (This is \em{not} supported in Delphi)
  514. The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the
  515. \var{ShortDateFormat} variable.
  516. \Errors
  517. On error (e.g. an invalid date or invalid character),
  518. an \var{EConvertError} exception is raised.
  519. \SeeAlso
  520. \seef{StrToTime}, \seef{DateToStr}n \seef{TimeToStr}.
  521. \end{function}
  522. \latex{\lstinputlisting{sysutex/ex19.pp}}
  523. \html{\input{sysutex/ex19.tex}}
  524. \begin{function}{StrToDateTime}
  525. \Declaration
  526. Function StrToDateTime(const S: string): TDateTime;
  527. \Description
  528. \var{StrToDateTime} converts the string \var{S} to a \var{TDateTime} date
  529. and time value. The Date must consist of 1 to three digits, separated by the
  530. \var{DateSeparator} character. If two numbers are given, they
  531. are supposed to form the day and month of the current year. If only
  532. one number is given, it is supposed to represent the day of the
  533. current month. (This is \em{not} supported in Delphi)
  534. The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the
  535. \var{ShortDateFormat} variable.
  536. \Errors
  537. On error (e.g. an invalid date or invalid character),
  538. an \var{EConvertError} exception is raised.
  539. \SeeAlso
  540. \seef{StrToDate}, \seef{StrToTime}, \seef{DateTimeToStr}
  541. \end{function}
  542. \latex{\lstinputlisting{sysutex/ex20.pp}}
  543. \html{\input{sysutex/ex20.tex}}
  544. \begin{function}{StrToTime}
  545. \Declaration
  546. Function StrToTime(const S: string): TDateTime;
  547. \Description
  548. \var{StrToTime} converts the string \var{S} to a \var{TDateTime} time
  549. value. The time must consist of 1 to 4 digits, separated by the
  550. \var{TimeSeparator} character. If two numbers are given, they
  551. are supposed to form the hour and minutes.
  552. \Errors
  553. On error (e.g. an invalid date or invalid character),
  554. an \var{EConvertError} exception is raised.
  555. \SeeAlso
  556. \seef{StrToDate}, \seef{StrToDateTime}, \seef{TimeToStr}
  557. \end{function}
  558. \latex{\lstinputlisting{sysutex/ex21.pp}}
  559. \html{\input{sysutex/ex21.tex}}
  560. \begin{function}{SystemTimeToDateTime}
  561. \Declaration
  562. Function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
  563. \Description
  564. \var{SystemTimeToDateTime} converts a \var{TSystemTime} record to a
  565. \var{TDateTime} style date/time indication.
  566. \Errors
  567. None.
  568. \SeeAlso
  569. \seep{DateTimeToSystemTime}
  570. \end{function}
  571. \latex{\lstinputlisting{sysutex/ex22.pp}}
  572. \html{\input{sysutex/ex22.tex}}
  573. \begin{function}{Time}
  574. \Declaration
  575. Function Time: TDateTime;
  576. \Description
  577. \var{Time} returns the current time in \var{TDateTime} format. The date
  578. part of the \var{TDateTimeValue} is set to zero.
  579. \Errors
  580. None.
  581. \SeeAlso
  582. \seef{Now}, \seef{Date}
  583. \end{function}
  584. \latex{\lstinputlisting{sysutex/ex23.pp}}
  585. \html{\input{sysutex/ex23.tex}}
  586. \begin{function}{TimeStampToDateTime}
  587. \Declaration
  588. Function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;
  589. \Description
  590. \var{TimeStampToDateTime} converts \var{TimeStamp} to a \var{TDateTime}
  591. format variable. It is the inverse operation of \seef{DateTimeToTimeStamp}.
  592. \Errors
  593. None.
  594. \SeeAlso
  595. \seef{DateTimeToTimeStamp}, \seef{TimeStampToMSecs}
  596. \end{function}
  597. \latex{\lstinputlisting{sysutex/ex24.pp}}
  598. \html{\input{sysutex/ex24.tex}}
  599. \begin{function}{TimeStampToMSecs}
  600. \Declaration
  601. Function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
  602. \Description
  603. \var{TimeStampToMSecs} converts {TimeStamp} to the number of seconds
  604. since \var{1/1/0001}.
  605. Use \var{TTimeStamp} variables if you need to keep very precise track of
  606. time.
  607. \Errors
  608. None.
  609. \SeeAlso
  610. \seef{MSecsToTimeStamp}, \seef{TimeStampToDateTime}
  611. \end{function}
  612. For an example, see \seef{MSecsToTimeStamp}.
  613. \begin{function}{TimeToStr}
  614. \Declaration
  615. Function TimeToStr(Time: TDateTime): string;
  616. \Description
  617. \var{TimeToStr} converts the time in \var{Time} to a string. It uses
  618. the \var{ShortTimeFormat} variable to see what formatting needs to be
  619. applied. It is therefor entirely equivalent to a
  620. \var{FormatDateTime('t',Time)} call.
  621. \Errors
  622. None.
  623. \SeeAlso
  624. \end{function}
  625. \latex{\lstinputlisting{sysutex/ex25.pp}}
  626. \html{\input{sysutex/ex25.tex}}
  627. \section{Disk functions}
  628. \begin{functionl}{AddDisk (Linux only)}{AddDisk}
  629. \Declaration
  630. Function AddDisk (Const PAth : String) : Longint;
  631. \Description
  632. On Linux both the \seef{DiskFree} and \seef{DiskSize} functions need a
  633. file on the specified drive, since is required for the statfs system call.
  634. These filenames are set in drivestr[0..26], and the first 4 have been
  635. preset to :
  636. \begin{description}
  637. \item[Disk 0] \var{'.'} default drive - hence current directory is used.
  638. \item[Disk 1] \var{'/fd0/.'} floppy drive 1.
  639. \item[Disk 2] \var{'/fd1/.'} floppy drive 2.
  640. \item[Disk 3] \var{'/'} \file{C:} equivalent of DOS is the root partition.
  641. \end{description}
  642. Drives 4..26 can be set by your own applications with the \var{AddDisk} call.
  643. The \var{AddDisk} call adds \var{Path} to the names of drive files, and
  644. returns the number of the disk that corresponds to this drive. If you
  645. add more than 21 drives, the count is wrapped to 4.
  646. \Errors
  647. None.
  648. \SeeAlso
  649. \seefl{DiskFree}{DiskFreeSys}, \seefl{DiskSize}{DiskSizeSys}
  650. \end{functionl}
  651. \begin{function}{CreateDir}
  652. \Declaration
  653. Function CreateDir(Const NewDir : String) : Boolean;
  654. \Description
  655. \var{CreateDir} creates a new directory with name \var{NewDir}.
  656. If the directory doesn't contain an absolute path, then the directory is
  657. created below the current working directory.
  658. The function returns \var{True} if the directory was successfully
  659. created, \var{False} otherwise.
  660. \Errors
  661. In case of an error, the function returns \var{False}.
  662. \SeeAlso
  663. \seef{RemoveDir}
  664. \end{function}
  665. \latex{\lstinputlisting{sysutex/ex26.pp}}
  666. \html{\input{sysutex/ex26.tex}}
  667. \begin{functionl}{DiskFree}{DiskFreeSys}
  668. \Declaration
  669. Function DiskFree(Drive : Byte) : Longint;
  670. \Description
  671. \var{DiskFree} returns the free space (in bytes) on disk \var{Drive}.
  672. Drive is the number of the disk drive:
  673. \begin{description}
  674. \item[0] for the current drive.
  675. \item[1] for the first floppy drive.
  676. \item[2] for the second floppy drive.
  677. \item[3] for the first hard-disk parttion.
  678. \item[4-26] for all other drives and partitions.
  679. \end{description}
  680. {\em Remark} Under \linux, and Unix in general, the concept of disk is
  681. different than the \dos one, since the filesystem is seen as one big
  682. directory tree. For this reason, the \var{DiskFree} and \seef{DiskSize}
  683. functions must be mimicked using filenames that reside on the partitions.
  684. For more information, see \seef{AddDisk}
  685. \Errors
  686. On error, \var{-1} is returned.
  687. \SeeAlso
  688. \seefl{DiskSize}{DiskSizeSys}, \seef{AddDisk}
  689. \end{functionl}
  690. \latex{\lstinputlisting{sysutex/ex27.pp}}
  691. \html{\input{sysutex/ex27.tex}}
  692. \begin{functionl}{DiskSize}{DiskSizeSys}
  693. \Declaration
  694. Function DiskSize(Drive : Byte) : Longint;
  695. \Description
  696. \var{DiskSize} returns the size (in bytes) of disk \var{Drive}.
  697. Drive is the number of the disk drive:
  698. \begin{description}
  699. \item[0] for the current drive.
  700. \item[1] for the first floppy drive.
  701. \item[2] for the second floppy drive.
  702. \item[3] for the first hard-disk parttion.
  703. \item[4-26] for all other drives and partitions.
  704. \end{description}
  705. {\em Remark} Under \linux, and Unix in general, the concept of disk is
  706. different than the \dos one, since the filesystem is seen as one big
  707. directory tree. For this reason, the \seef{DiskFree} and \var{DiskSize}
  708. functions must be mimicked using filenames that reside on the partitions.
  709. For more information, see \seef{AddDisk}
  710. \Errors
  711. On error, \var{-1} is returned.
  712. \SeeAlso
  713. \seefl{DiskFree}{DiskFreeSys}, \seef{AddDisk}
  714. \end{functionl}
  715. For an example, see \seefl{DiskFree}{DiskFreeSys}.
  716. \begin{function}{GetCurrentDir}
  717. \Declaration
  718. Function GetCurrentDir : String;
  719. \Description
  720. \var{GetCurrentDir} returns the current working directory.
  721. \Errors
  722. None.
  723. \SeeAlso
  724. \seef{SetCurrentDir}, \seef{DiskFree}, \seef{DiskSize}
  725. \end{function}
  726. \latex{\lstinputlisting{sysutex/ex28.pp}}
  727. \html{\input{sysutex/ex28.tex}}
  728. \begin{function}{RemoveDir}
  729. \Declaration
  730. Function RemoveDir(Const Dir : String) : Boolean;
  731. \Description
  732. \var{RemoveDir} removes directory \var{Dir} from the disk.
  733. If the directory is not absolue, it is appended to the current working
  734. directory.
  735. \Errors
  736. In case of error (e.g. the directory isn't empty) the function returns
  737. \var{False}. If successful, \var{True} is returned.
  738. \SeeAlso
  739. \end{function}
  740. For an example, see \seef{CreateDir}.
  741. \begin{function}{SetCurrentDir}
  742. \Declaration
  743. Function SetCurrentDir(Const NewDir : String) : Boolean;
  744. \Description
  745. \var{SetCurrentDir} sets the current working directory of your program
  746. to \var{NewDir}. It returns \var{True} if the function was successfull,
  747. \var{False} otherwise.
  748. \Errors
  749. In case of error, \var{False} is returned.
  750. \SeeAlso
  751. \seef{GetCurrentDir}
  752. \end{function}
  753. \latex{\lstinputlisting{sysutex/ex29.pp}}
  754. \html{\input{sysutex/ex29.tex}}
  755. \section{File handling functions}
  756. \begin{function}{ChangeFileExt}
  757. \Declaration
  758. Function ChangeFileExt(const FileName, Extension: string): string;
  759. \Description
  760. \var{ChangeFileExt} changes the file extension in \var{FileName} to
  761. \var{Extension}.
  762. The extension \var{Extension} includes the starting \var{.} (dot).
  763. The previous extension of \var{FileName} are all characters after the
  764. last \var{.}, the \var{.} character included.
  765. If \var{FileName} doesn't have an extension, \var{Extension} is just
  766. appended.
  767. \Errors
  768. None.
  769. \SeeAlso
  770. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExpandFileName}
  771. \end{function}
  772. \begin{function}{DeleteFile}
  773. \Declaration
  774. Function DeleteFile(Const FileName : String) : Boolean;
  775. \Description
  776. \var{DeleteFile} deletes file \var{FileName} from disk. The function
  777. returns \var{True} if the file was successfully removed, \var{False}
  778. otherwise.
  779. \Errors
  780. On error, \var{False} is returned.
  781. \SeeAlso
  782. \seef{FileCreate}, \seef{FileExists}
  783. \end{function}
  784. \latex{\lstinputlisting{sysutex/ex31.pp}}
  785. \html{\input{sysutex/ex31.tex}}
  786. \begin{procedure}{DoDirSeparators}
  787. \Declaration
  788. Procedure DoDirSeparators(Var FileName : String);
  789. \Description
  790. This function replaces all directory separators \var{'\' and '/'}
  791. to the directory separator character for the current system.
  792. \Errors
  793. None.
  794. \SeeAlso
  795. \seef{ExtractFileName}, \seef{ExtractFilePath}
  796. \end{procedure}
  797. \latex{\lstinputlisting{sysutex/ex32.pp}}
  798. \html{\input{sysutex/ex32.tex}}
  799. \begin{function}{ExpandFileName}
  800. \Declaration
  801. Function ExpandFileName(Const FileName : string): String;
  802. \Description
  803. \var{ExpandFileName} expands the filename to an absolute filename.
  804. It changes all directory separator characters to the one appropriate for the
  805. system first.
  806. \Errors
  807. None.
  808. \SeeAlso
  809. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  810. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  811. \end{function}
  812. \latex{\lstinputlisting{sysutex/ex33.pp}}
  813. \html{\input{sysutex/ex33.tex}}
  814. \begin{function}{ExpandUNCFileName}
  815. \Declaration
  816. Function ExpandUNCFileName(Const FileName : string): String;
  817. \Description
  818. \var{ExpandUNCFileName} runs \seef{ExpandFileName} on \var{FileName}
  819. and then attempts to replace the driveletter by the name of a shared disk.
  820. \Errors
  821. \SeeAlso
  822. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  823. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  824. \end{function}
  825. \begin{function}{ExtractFileDir}
  826. \Declaration
  827. Function ExtractFileDir(Const FileName : string): string;
  828. \Description
  829. \var{ExtractFileDir} returns only the directory part of \var{FileName},
  830. not including a driveletter. The directory name has NO ending directory
  831. separator, in difference with \seef{ExtractFilePath}.
  832. \Errors
  833. None.
  834. \SeeAlso
  835. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  836. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  837. \end{function}
  838. \latex{\lstinputlisting{sysutex/ex34.pp}}
  839. \html{\input{sysutex/ex34.tex}}
  840. \begin{function}{ExtractFileDrive}
  841. \Declaration
  842. Function ExtractFileDrive(const FileName: string): string;
  843. \Description
  844. \var{Extract}
  845. \Errors
  846. \SeeAlso
  847. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  848. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  849. \end{function}
  850. For an example, see \seef{ExtractFileDir}.
  851. \begin{function}{ExtractFileExt}
  852. \Declaration
  853. Function ExtractFileExt(const FileName: string): string;
  854. \Description
  855. \var{ExtractFileExt} returns the extension (including the
  856. \var{.}(dot) character) of \var{FileName}.
  857. \Errors
  858. None.
  859. \SeeAlso
  860. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  861. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  862. \end{function}
  863. For an example, see \seef{ExtractFileDir}.
  864. \begin{function}{ExtractFileName}
  865. \Declaration
  866. Function ExtractFileName(const FileName: string): string;
  867. \Description
  868. \var{ExtractFileName} returns the filename part from \var{FileName}.
  869. The filename consists of all characters after the last directory separator
  870. character ('/' or '\') or drive letter.
  871. The full filename can always be reconstucted by concatenating the result
  872. of \seef{ExtractFilePath} and \var{ExtractFileName}.
  873. \Errors
  874. None.
  875. \SeeAlso
  876. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  877. \seef{ExtractFileDrive}, \seef{ExtractFileExt},\seef{ExtractRelativePath}
  878. \end{function}
  879. For an example, see \seef{ExtractFileDir}.
  880. \begin{function}{ExtractFilePath}
  881. \Declaration
  882. Function ExtractFilePath(const FileName: string): string;
  883. \Description
  884. \var{ExtractFilePath} returns the path part (including driveletter) from
  885. \var{FileName}. The path consists of all characters before the last
  886. directory separator character ('/' or '\'), including the directory
  887. separator itself.
  888. In case there is only a drive letter, that will be returned.
  889. The full filename can always be reconstucted by concatenating the result
  890. of \var{ExtractFilePath} and \seef{ExtractFileName}.
  891. \Errors
  892. None.
  893. \SeeAlso
  894. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  895. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  896. \end{function}
  897. For an example, see \seef{ExtractFileDir}.
  898. \begin{function}{ExtractRelativePath}
  899. \Declaration
  900. Function ExtractRelativePath(Const BaseName,DestNAme : String): String;
  901. \Description
  902. \var{ExtractRelativePath} constructs a relative path to go from
  903. \var{BaseName} to \var{DestName}. If \var{DestName} is on another drive
  904. (Not on Linux) then the whole \var{Destname} is returned.
  905. {\em Note:} This function does not exist in the Delphi unit.
  906. \Errors
  907. None.
  908. \SeeAlso
  909. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  910. \seef{ExtractFileDrive}, \seef{ExtractFileExt},
  911. \end{function}
  912. \latex{\lstinputlisting{sysutex/ex35.pp}}
  913. \html{\input{sysutex/ex35.tex}}
  914. \begin{function}{FileAge}
  915. \Declaration
  916. Function FileAge(Const FileName : String): Longint;
  917. \Description
  918. \var{FileAge} returns the last modification time of file \var{FileName}.
  919. The FileDate format can be transformed to \var{TDateTime} format with the
  920. \seef{FileDateToDateTime} function.
  921. \Errors
  922. In case of errors, \var{-1} is returned.
  923. \SeeAlso
  924. \seef{FileDateToDateTime}, \seef{FileExists}, \seef{FileGetAttr}
  925. \end{function}
  926. \latex{\lstinputlisting{sysutex/ex36.pp}}
  927. \html{\input{sysutex/ex36.tex}}
  928. \begin{procedure}{FileClose}
  929. \Declaration
  930. Procedure FileClose(Handle : Longint);
  931. \Description
  932. \var{FileClose} closes the file handle \var{Handle}. After this call,
  933. attempting to read or write from the handle will result in an error.
  934. \Errors
  935. None.
  936. \SeeAlso
  937. \seef{FileCreate}, \seef{FileWrite}, \seef{FileOpen}, \seef{FileRead},
  938. \seef{FileTruncate}, \seef{FileSeek}
  939. \end{procedure}
  940. For an example, see \seef{FileCreate}
  941. \begin{function}{FileCreate}
  942. \Declaration
  943. Function FileCreate(Const FileName : String) : Longint;
  944. \Description
  945. \var{FileCreate} creates a new file with name \var{FileName} on the disk and
  946. returns a file handle which can be used to read or write from the file with
  947. the \seef{FileRead} and \seef{FileWrite} functions.
  948. If a file with name \var{FileName} already existed on the disk, it is
  949. overwritten.
  950. \Errors
  951. If an error occurs (e.g. disk full or non-existent path), the function
  952. returns \var{-1}.
  953. \SeeAlso
  954. \seep{FileClose}, \seef{FileWrite}, \seef{FileOpen}, \seef{FileRead},
  955. \seef{FileTruncate}, \seef{FileSeek}
  956. \end{function}
  957. \latex{\lstinputlisting{sysutex/ex37.pp}}
  958. \html{\input{sysutex/ex37.tex}}
  959. \begin{function}{FileExists}
  960. \Declaration
  961. Function FileExists(Const FileName : String) : Boolean;
  962. \Description
  963. \var{FileExists} returns \var{True} if a file with name \var{FileName}
  964. exists on the disk, \var{False} otherwise.
  965. \Errors
  966. None.
  967. \SeeAlso
  968. \seef{FileAge}, \seef{FileGetAttr}, \seef{FileSetAttr}
  969. \end{function}
  970. \latex{\lstinputlisting{sysutex/ex38.pp}}
  971. \html{\input{sysutex/ex38.tex}}
  972. \begin{function}{FileGetAttr}
  973. \Declaration
  974. Function FileGetAttr(Const FileName : String) : Longint;
  975. \Description
  976. \var{FileGetAttr} returns the attribute settings of file
  977. \var{FileName}. The attribute is a \var{OR}-ed combination
  978. of the following constants:
  979. \begin{description}
  980. \item[faReadOnly] The file is read-only.
  981. \item[faHidden] The file is hidden. (On \linux, this means that the filename
  982. starts with a dot)
  983. \item[faSysFile] The file is a system file (On \linux, this means that the
  984. file is a character, block or FIFO file).
  985. \item[faVolumeId] Volume Label. Not possible under \linux.
  986. \item[faDirectory] File is a directory.
  987. \item[faArchive] file is an archive. Not possible on \linux.
  988. \end{description}
  989. \Errors
  990. In case of error, -1 is returned.
  991. \SeeAlso
  992. \seef{FileSetAttr}, \seef{FileAge}, \seef{FileGetDate}.
  993. \end{function}
  994. \latex{\lstinputlisting{sysutex/ex40.pp}}
  995. \html{\input{sysutex/ex40.tex}}
  996. \begin{function}{FileGetDate}
  997. \Declaration
  998. Function FileGetDate(Handle : Longint) : Longint;
  999. \Description
  1000. \var{FileGetdate} returns the filetime of the opened file with filehandle
  1001. \var{Handle}. It is the same as \seef{FileAge}, with this difference that
  1002. \var{FileAge} only needs the file name, while \var{FilegetDate} needs an
  1003. open file handle.
  1004. \Errors
  1005. On error, -1 is returned.
  1006. \SeeAlso
  1007. \seef{FileAge}
  1008. \end{function}
  1009. \latex{\lstinputlisting{sysutex/ex39.pp}}
  1010. \html{\input{sysutex/ex39.tex}}
  1011. \begin{function}{FileOpen}
  1012. \Declaration
  1013. Function FileOpen(Const FileName : string; Mode : Integer) : Longint;
  1014. \Description
  1015. \var{FileOpen} opens a file with name \var{FileName} with mode \var{Mode}.
  1016. \var{Mode} can be one of the following constants:
  1017. \begin{description}
  1018. \item[fmOpenRead] The file is opened for reading.
  1019. \item[fmOpenWrite] The file is opened for writing.
  1020. \item[fmOpenReadWrite] The file is opened for reading and writing.
  1021. \end{description}
  1022. If the file has been successfully opened, it can be read from or written to
  1023. (depending on the \var{Mode} parameter) with the \seef{FileRead} and
  1024. \var{FileWrite} functions.
  1025. Remark that you cannot open a file if it doesn't exist yet, i.e. it will not
  1026. be created for you. If you want tp create a new file, or overwrite an old
  1027. one, use the \seef{FileCreate} function.
  1028. \Errors
  1029. On Error, -1 is returned.
  1030. \SeeAlso
  1031. \seep{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileRead},
  1032. \seef{FileTruncate}, \seef{FileSeek}
  1033. \end{function}
  1034. For an example, see \seef{FileRead}
  1035. \begin{function}{FileRead}
  1036. \Declaration
  1037. Function FileRead(Handle : Longint; Var Buffer; Count : longint) : Longint;
  1038. \Description
  1039. \var{FileRead} reads \var{Count} bytes from file-handle \var{Handle} and
  1040. stores them into \var{Buffer}. Buffer must be at least \var{Count} bytes
  1041. long. No checking on this is performed, so be careful not to overwrite any
  1042. memory. \var{Handle} must be the result of a \seef{FileOpen} call.
  1043. \Errors
  1044. On error, -1 is returned.
  1045. \SeeAlso
  1046. \seep{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen},
  1047. \seef{FileTruncate}, \seef{FileSeek}
  1048. \end{function}
  1049. For an example, see \seef{FileOpen}
  1050. \begin{function}{FileSearch}
  1051. \Declaration
  1052. Function FileSearch(Const Name, DirList : String) : String;
  1053. \Description
  1054. \var{FileSearch} looks for the file \var{Name} in \var{DirList}, where
  1055. dirlist is a list of directories, separated by semicolons or colons.
  1056. It returns the full filename of the first match found.
  1057. \Errors
  1058. On error, an empty string is returned.
  1059. \SeeAlso
  1060. \seef{ExpandFileName}, \seef{FindFirst}
  1061. \end{function}
  1062. \latex{\lstinputlisting{sysutex/ex41.pp}}
  1063. \html{\input{sysutex/ex41.tex}}
  1064. \begin{function}{FileSeek}
  1065. \Declaration
  1066. Function FileSeek(Handle,Offset,Origin : Longint) : Longint;
  1067. \Description
  1068. \var{FileSeek} sets the file pointer on position \var{Offset}, starting from
  1069. \var{Origin}. Origin can be one of the following values:
  1070. \begin{description}
  1071. \item[fsFromBeginning] \var{Offset} is relative to the first byte of the file. This
  1072. position is zero-based. i.e. the first byte is at offset 0.
  1073. \item[fsFromCurrent] \var{Offset} is relative to the current position.
  1074. \item[fsFromEnd] \var{Offset} is relative to the end of the file. This means
  1075. that \var{Offset} can only be zero or negative in this case.
  1076. \end{description}
  1077. If successfull, the function returns the new file position, relative to the
  1078. beginning of the file.
  1079. {\em Remark:} The abovementioned constants do not exist in Delphi.
  1080. \Errors
  1081. On error, -1 is returned.
  1082. \SeeAlso
  1083. \seep{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen}
  1084. \seef{FileRead}, \seef{FileTruncate}
  1085. \end{function}
  1086. \latex{\lstinputlisting{sysutex/ex42.pp}}
  1087. \html{\input{sysutex/ex42.tex}}
  1088. For an example, see \seef{FileCreate}
  1089. \begin{functionl}{FileSetAttr (Not on Linux)}{FileSetAttr}
  1090. \Declaration
  1091. Function FileSetAttr(Const Filename : String; Attr: longint) : Longint;
  1092. \Description
  1093. \var{FileSetAttr} sets the attributes of \var{FileName} to \var{Attr}.
  1094. If the function was successful, 0 is returned, -1 otherwise.
  1095. \var{Attr} can be set to an OR-ed combination of the pre-defined
  1096. \var{faXXX} constants.
  1097. \Errors
  1098. On error, -1 is returned (always on linux).
  1099. \SeeAlso
  1100. \seef{FileGetAttr}, \seef{FileGetDate}, \seef{FileSetDate}.
  1101. \end{functionl}
  1102. \begin{functionl}{FileSetDate (Not on Linux)}{FileSetDate}
  1103. \Declaration
  1104. Function FileSetDate(Handle,Age : Longint) : Longint;
  1105. \Description
  1106. \var{FileSetDate} sets the file date of the file with handle \var{Handle}
  1107. to \var{Age}, where \var{Age} is a DOS date-and-time stamp value.
  1108. The function returns zero of successfull.
  1109. \Errors
  1110. On Linux, -1 is always returned, since this is impossible to implement.
  1111. On Windows and DOS, a negative error code is returned.
  1112. \SeeAlso
  1113. \end{functionl}
  1114. \begin{function}{FileTruncate}
  1115. \Declaration
  1116. Function FileTruncate(Handle,Size: Longint) : boolean;
  1117. \Description
  1118. \var{FileTruncate} truncates the file with handle \var{Handle} to
  1119. \var{Size} bytes. The file must have been opened for writing prior
  1120. to this call. The function returns \var{True} is successful, \var{False}
  1121. otherwise.
  1122. \Errors
  1123. On error, the function returns \var{False}.
  1124. \SeeAlso
  1125. \seep{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen}
  1126. \seef{FileRead}, \seef{FileSeek}
  1127. \end{function}
  1128. For an example, see \seef{FileCreate}.
  1129. \begin{function}{FileWrite}
  1130. \Declaration
  1131. Function FileWrite(Handle : Longint; Var Buffer; Count : Longint) : Longint;
  1132. \Description
  1133. \var{FileWrite} writes \var{Count} bytes from \var{Buffer} to the file with
  1134. handle \var{Handle}. Prior to this call, the file must have been opened
  1135. for writing. \var{Buffer} must be at least \var{Count} bytes large, or
  1136. a memory access error may occur.
  1137. The function returns the number of bytes written, or -1 in case of an
  1138. error.
  1139. \Errors
  1140. In case of error, -1 is returned.
  1141. \SeeAlso
  1142. \seep{FileClose}, \seef{FileCreate}, \seef{FileOpen}
  1143. \seef{FileRead}, \seef{FileTruncate}, \seef{FileSeek}
  1144. \end{function}
  1145. For an example, see \seef{FileCreate}.
  1146. \begin{procedurel}{FindClose}{FindCloseSys}
  1147. \Declaration
  1148. Procedure FindClose(Var F : TSearchrec);
  1149. \Description
  1150. \var{FindClose} ends a series of \seef{FindFirst}/\seef{FindNext} calls,
  1151. and frees any memory used by these calls. It is {\em absolutely} necessary
  1152. to do this call, or huge memory losses may occur.
  1153. \Errors
  1154. None.
  1155. \SeeAlso
  1156. \seef{FindFirst}, \seef{FindNext}.
  1157. \end{procedurel}
  1158. For an example, see \seef{FindFirst}.
  1159. \begin{function}{FindFirst}
  1160. \Declaration
  1161. Function FindFirst(Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
  1162. \Description
  1163. \var{FindFirst} looks for files that match the name (possibly with
  1164. wildcards) in \var{Path} and attributes \var{Attr}. It then fills up the
  1165. \var{Rslt} record with data gathered about the file. It returns 0 if a file
  1166. matching the specified criteria is found, a nonzero value (-1 on linux)
  1167. otherwise.
  1168. The \var{Rslt} record can be fed to subsequent calls to \var{FindNext}, in
  1169. order to find other files matching the specifications.
  1170. {\em remark:} A \var{FindFirst} call must {\em always} be followed by a
  1171. \seepl{FindClose}{FindCloseSys} call with the same \var{Rslt} record. Failure to do so will
  1172. result in memory loss.
  1173. \Errors
  1174. On error the function returns -1 on linux, a nonzero error code on Windows.
  1175. \SeeAlso
  1176. \seep{FindClose}{FindCloseSys}, \seef{FindNext}.
  1177. \end{function}
  1178. \latex{\lstinputlisting{sysutex/ex43.pp}}
  1179. \html{\input{sysutex/ex43.tex}}
  1180. \begin{function}{FindNext}
  1181. \Declaration
  1182. Function FindNext(Var Rslt : TSearchRec) : Longint;
  1183. \Description
  1184. \var{FindNext} finds a next occurrence of a search sequence initiated by
  1185. \var{FindFirst}. If another record matching the criteria in Rslt is found, 0
  1186. is returned, a nonzero constant is returned otherwise.
  1187. {\em remark:} The last \var{FindNext} call must {\em always} be followed by a
  1188. \var{FindClose} call with the same \var{Rslt} record. Failure to do so will
  1189. result in memory loss.
  1190. \Errors
  1191. On error (no more file is found), a nonzero constant is returned.
  1192. \SeeAlso
  1193. \seef{FindFirst}, \seep{FindClose}
  1194. \end{function}
  1195. For an example, see \seef{FindFirst}
  1196. \begin{function}{GetDirs}
  1197. \Declaration
  1198. Function GetDirs(Var DirName : String; Var Dirs : Array of pchar) : Longint;
  1199. \Description
  1200. \var{GetDirs} splits DirName in a null-byte separated list of directory names,
  1201. \var{Dirs} is an array of \var{PChars}, pointing to these directory names.
  1202. The function returns the number of directories found, or -1 if none were found.
  1203. DirName must contain only OSDirSeparator as Directory separator chars.
  1204. \Errors
  1205. None.
  1206. \SeeAlso
  1207. \seef{ExtractRelativePath}
  1208. \end{function}
  1209. \latex{\lstinputlisting{sysutex/ex45.pp}}
  1210. \html{\input{sysutex/ex45.tex}}
  1211. \begin{function}{RenameFile}
  1212. \Declaration
  1213. Function RenameFile(Const OldName, NewName : String) : Boolean;
  1214. \Description
  1215. \var{RenameFile} renames a file from \var{OldName} to \var{NewName}. The
  1216. function returns \var{True} if successful, \var{False} otherwise.
  1217. {\em Remark:} you cannot rename across disks or partitions.
  1218. \Errors
  1219. On Error, \var{False} is returned.
  1220. \SeeAlso
  1221. \seef{DeleteFile}
  1222. \end{function}
  1223. \latex{\lstinputlisting{sysutex/ex44.pp}}
  1224. \html{\input{sysutex/ex44.tex}}
  1225. \begin{function}{SetDirSeparators}
  1226. \Declaration
  1227. Function SetDirSeparators(Const FileName : String) : String;
  1228. \Description
  1229. \var{SetDirSeparators} returns \var{FileName} with all possible
  1230. DirSeparators replaced by \var{OSDirSeparator}.
  1231. \Errors
  1232. None.
  1233. \SeeAlso
  1234. \seef{ExpandFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir}
  1235. \end{function}
  1236. \latex{\lstinputlisting{sysutex/ex47.pp}}
  1237. \html{\input{sysutex/ex47.tex}}
  1238. \section{PChar functions}
  1239. \subsection{Introduction}
  1240. Most PChar functions are the same as their counterparts in the \file{STRINGS}
  1241. unit. The following functions are the same :
  1242. \begin{enumerate}
  1243. \item \seef{StrCat} : Concatenates two \var{PChar} strings.
  1244. \item \seef{StrComp} : Compares two \var{PChar} strings.
  1245. \item \seef{StrCopy} : Copies a \var{PChar} string.
  1246. \item \seef{StrECopy} : Copies a \var{PChar} string and returns a pointer to
  1247. the terminating null byte.
  1248. \item \seef{StrEnd} : Returns a pointer to the terminating null byte.
  1249. \item \seef{StrIComp} : Case insensitive compare of 2 \var{PChar} strings.
  1250. \item \seef{StrLCat} : Appends at most L characters from one \var{PChar} to
  1251. another \var{PChar}.
  1252. \item \seef{StrLComp} : Case sensitive compare of at most L characters of 2
  1253. \var{PChar} strings.
  1254. \item \seef{StrLCopy} : Copies at most L characters from one \var{PChar} to
  1255. another.
  1256. \item \seef{StrLen} : Returns the length (exclusive terminating null byte)
  1257. of a \var{PChar} string.
  1258. \item \seef{StrLIComp} : Case insensitive compare of at most L characters of 2
  1259. \var{PChar} strings.
  1260. \item \seef{StrLower} : Converts a \var{PChar} to all lowercase letters.
  1261. \item \seef{StrMove} : Moves one \var{PChar} to another.
  1262. \item \seef{StrNew} : Makes a copy of a \var{PChar} on the heap, and returns
  1263. a pointer to this copy.
  1264. \item \seef{StrPos} : Returns the position of one \var{PChar} string in
  1265. another?
  1266. \item \seef{StrRScan} : returns a pointer to the last occurrence of on
  1267. \var{PChar} string in another one.
  1268. \item \seef{StrScan} : returns a pointer to the first occurrence of on
  1269. \var{PChar} string in another one.
  1270. \item \seef{StrUpper} : Converts a \var{PChar} to all uppercase letters.
  1271. \end{enumerate}
  1272. The subsequent functions are different from their counterparts in
  1273. \file{STRINGS}, although the same examples can be used.
  1274. \begin{functionl}{StrAlloc}{StrAllocSys}
  1275. \Declaration
  1276. Function StrAlloc(Size: cardinal): PChar;
  1277. \Description
  1278. \var{StrAlloc} reserves memory on the heap for a string with length \var{Len},
  1279. terminating \var{\#0} included, and returns a pointer to it.
  1280. Additionally, \var{StrAlloc} allocates 4 extra bytes to store the size of
  1281. the allocated memory. Therefore this function is NOT compatible with the
  1282. \seef{StrAlloc} function of the \var{Strings} unit.
  1283. \Errors
  1284. None.
  1285. \SeeAlso
  1286. \seef{StrBufSize}, \seepl{StrDispose}{StrDisposeSys}, \seef{StrAlloc}
  1287. \end{functionl}
  1288. For an example, see \seef{StrBufSize}.
  1289. \begin{function}{StrBufSize}
  1290. \Declaration
  1291. Function StrBufSize(var Str: PChar): cardinal;
  1292. \Description
  1293. \var{StrBufSize} returns the memory allocated for \var{Str}. This function
  1294. ONLY gives the correct result if \var{Str} was allocated using
  1295. \seefl{StrAlloc}{StrAllocSys}.
  1296. \Errors
  1297. If no more memory is available, a runtime error occurs.
  1298. \SeeAlso
  1299. \seefl{StrAlloc}{StrAllocSys}.\seepl{StrDispose}{StrDisposeSys}.
  1300. \end{function}
  1301. \latex{\lstinputlisting{sysutex/ex46.pp}}
  1302. \html{\input{sysutex/ex46.tex}}
  1303. \begin{procedurel}{StrDispose}{StrDisposeSys}
  1304. \Declaration
  1305. Procedure StrDispose(var Str: PChar);
  1306. \Description
  1307. \var{StrDispose} frees any memory allocated for \var{Str}. This function
  1308. will only function correctly if \var{Str} has been allocated using
  1309. \seefl{StrAlloc}{StrAllocSys} from the \file{SYSUTILS} unit.
  1310. \Errors
  1311. If an invalid pointer is passed, or a pointer not allocated with
  1312. \var{StrAlloc}, an error may occur.
  1313. \SeeAlso
  1314. \seef{StrBufSize}, \seefl{StrAlloc}{StrAllocSys}, \seep{StrDispose}
  1315. \end{procedurel}
  1316. For an example, see \seef{StrBufSize}.
  1317. \begin{functionl}{StrPCopy}{StrPCopySys}
  1318. \Declaration
  1319. Function StrPCopy(Dest: PChar; Source: string): PChar;
  1320. \Description
  1321. \var{StrPCopy} Converts the Ansistring in \var{Source} to a Null-terminated
  1322. string, and copies it to \var{Dest}. \var{Dest} needs enough room to contain
  1323. the string \var{Source}, i.e. \var{Length(Source)+1} bytes.
  1324. \Errors
  1325. No checking is performed to see whether \var{Dest} points to enough memory
  1326. to contain \var{Source}.
  1327. \SeeAlso
  1328. \seefl{StrPLCopy}{StrPLCopySys}, \seef{StrPCopy}
  1329. \end{functionl}
  1330. For an example, see \seef{StrPCopy}.
  1331. \begin{functionl}{StrPLCopy}{StrPLCopySys}
  1332. \Declaration
  1333. Function StrPLCopy(Dest: PChar; Source: string; MaxLen: cardinal): PChar;
  1334. \Description
  1335. \var{StrPLCopy} Converts maximally \var{MaxLen} characters of the
  1336. Ansistring in \var{Source} to a Null-terminated string, and copies
  1337. it to \var{Dest}. \var{Dest} needs enough room to contain
  1338. the characters.
  1339. \Errors
  1340. No checking is performed to see whether \var{Dest} points to enough memory
  1341. to contain L characters of \var{Source}.
  1342. \Errors
  1343. \SeeAlso
  1344. \seefl{StrPCopy}{StrPCopySys}.
  1345. \end{functionl}
  1346. \begin{functionl}{StrPas}{StrPasSys}
  1347. \Declaration
  1348. Function StrPas(Str: PChar): string;
  1349. \Description
  1350. Converts a null terminated string in \var{Str} to an Ansitring, and returns
  1351. this string. This string is NOT truncated at 255 characters as is the
  1352. \Errors
  1353. None.
  1354. \SeeAlso
  1355. \seef{StrPas}.
  1356. \end{functionl}
  1357. For an example, see \seef{StrPas}.
  1358. \section{String handling functions}
  1359. \begin{function}{AdjustLineBreaks}
  1360. \Declaration
  1361. Function AdjustLineBreaks(const S: string): string;
  1362. \Description
  1363. \var{AdjustLineBreaks} will change all \var{\#13} characters with
  1364. \var{\#13\#10} on \windowsnt and \dos. On \linux, all \var{\#13\#10}
  1365. character pairs are converted to \var{\#10} and single \var{\#13}
  1366. characters also.
  1367. \Errors
  1368. None.
  1369. \SeeAlso
  1370. \seef{AnsiCompareStr}, \seef{AnsiCompareText}
  1371. \end{function}
  1372. \latex{\lstinputlisting{sysutex/ex48.pp}}
  1373. \html{\input{sysutex/ex48.tex}}
  1374. \begin{function}{AnsiCompareStr}
  1375. \Declaration
  1376. Function AnsiCompareStr(const S1, S2: string): integer;
  1377. \Description
  1378. \var{AnsiCompareStr} compares two strings and returns the following
  1379. result:
  1380. \begin{description}
  1381. \item[<0] if \var{S1<S2}.
  1382. \item[0] if \var{S1=S2}.
  1383. \item[>0] if \var{S1>S2}.
  1384. \end{description}
  1385. the comparision takes into account Ansi characters, i.e. it takes
  1386. care of strange accented characters. Contrary to \seef{AnsiCompareText},
  1387. the comparision is case sensitive.
  1388. \Errors
  1389. None.
  1390. \SeeAlso
  1391. \seef{AdjustLineBreaks}, \seef{AnsiCompareText}
  1392. \end{function}
  1393. \latex{\lstinputlisting{sysutex/ex49.pp}}
  1394. \html{\input{sysutex/ex49.tex}}
  1395. \begin{function}{AnsiCompareText}
  1396. \Declaration
  1397. Function AnsiCompareText(const S1, S2: string): integer;
  1398. \Description
  1399. \Description
  1400. \var{AnsiCompareText} compares two strings and returns the following
  1401. result:
  1402. \begin{description}
  1403. \item[<0] if \var{S1<S2}.
  1404. \item[0] if \var{S1=S2}.
  1405. \item[>0] if \var{S1>S2}.
  1406. \end{description}
  1407. the comparision takes into account Ansi characters, i.e. it takes
  1408. care of strange accented characters. Contrary to \seef{AnsiCompareStr},
  1409. the comparision is case insensitive.
  1410. \Errors
  1411. None.
  1412. \SeeAlso
  1413. \seef{AdjustLineBreaks}, \seef{AnsiCompareText}
  1414. \end{function}
  1415. \latex{\lstinputlisting{sysutex/ex50.pp}}
  1416. \html{\input{sysutex/ex50.tex}}
  1417. \begin{function}{AnsiExtractQuotedStr}
  1418. \Declaration
  1419. Function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
  1420. \Description
  1421. \var{AnsiExtractQuotedStr} Returns \var{Src} as a string,, with \var{Quute}
  1422. characters removed from the beginning and end of the string, and double
  1423. \var{Quote} characters replaced by a single \var{Quote} characters.
  1424. As such, it revereses the action of \seef{AnsiQuotedStr}.
  1425. \Errors
  1426. None.
  1427. \SeeAlso
  1428. \seef{AnsiQuotedStr}
  1429. \end{function}
  1430. \latex{\lstinputlisting{sysutex/ex51.pp}}
  1431. \html{\input{sysutex/ex51.tex}}
  1432. \begin{function}{AnsiLastChar}
  1433. \Declaration
  1434. Function AnsiLastChar(const S: string): PChar;
  1435. \Description
  1436. This function returns a pointer to the last character of \var{S}.
  1437. Since multibyte characters are not yet supported, this is the same
  1438. as \var{@S[Length(S)])}.
  1439. \Errors
  1440. None.
  1441. \SeeAlso
  1442. \seef{AnsiStrLastChar}
  1443. \end{function}
  1444. \latex{\lstinputlisting{sysutex/ex52.pp}}
  1445. \html{\input{sysutex/ex52.tex}}
  1446. \begin{function}{AnsiLowerCase}
  1447. \Declaration
  1448. Function AnsiLowerCase(const s: string): string;
  1449. \Description
  1450. \var{AnsiLowerCase} converts the string \var{S} to lowercase characters
  1451. and returns the resulting string.
  1452. It takes into account the operating system language
  1453. settings when doing this, so spcial characters are converted correctly as
  1454. well.
  1455. {\em Remark} On linux, no language setting is taken in account yet.
  1456. \Errors
  1457. None.
  1458. \SeeAlso
  1459. \seef{AnsiUpperCase}, \seef{AnsiStrLower}, \seef{AnsiStrUpper}
  1460. \end{function}
  1461. \latex{\lstinputlisting{sysutex/ex53.pp}}
  1462. \html{\input{sysutex/ex53.tex}}
  1463. \begin{function}{AnsiQuotedStr}
  1464. \Declaration
  1465. Function AnsiQuotedStr(const S: string; Quote: char): string;
  1466. \Description
  1467. \var{AnsiQuotedString} quotes the string \var{S} and returns the result.
  1468. This means that it puts the \var{Quote} character at both the beginning and
  1469. end of the string and replaces any occurrence of \var{Quote} in \var{S}
  1470. with 2 \var{Quote} characters. The action of \var{AnsiQuotedString} can be
  1471. reversed by \seef{AnsiExtractQuotedStr}.
  1472. \Errors
  1473. None.
  1474. \SeeAlso
  1475. \seef{AnsiExtractQuotedStr}
  1476. \end{function}
  1477. For an example, see \seef{AnsiExtractQuotedStr}
  1478. \begin{function}{AnsiStrComp}
  1479. \Declaration
  1480. Function AnsiStrComp(S1, S2: PChar): integer;
  1481. \Description
  1482. \var{AnsiStrComp} compares 2 \var{PChar} strings, and returns the following
  1483. result:
  1484. \begin{description}
  1485. \item[<0] if \var{S1<S2}.
  1486. \item[0] if \var{S1=S2}.
  1487. \item[>0] if \var{S1>S2}.
  1488. \end{description}
  1489. The comparision of the two strings is case-sensitive.
  1490. The function does not yet take internationalization settings into account.
  1491. \Errors
  1492. None.
  1493. \SeeAlso
  1494. \seef{AnsiCompareText}, \seef{AnsiCompareStr}
  1495. \end{function}
  1496. \latex{\lstinputlisting{sysutex/ex54.pp}}
  1497. \html{\input{sysutex/ex54.tex}}
  1498. \begin{function}{AnsiStrIComp}
  1499. \Declaration
  1500. Function AnsiStrIComp(S1, S2: PChar): integer;
  1501. \Description
  1502. \var{AnsiStrIComp} compares 2 \var{PChar} strings, and returns the following
  1503. result:
  1504. \begin{description}
  1505. \item[<0] if \var{S1<S2}.
  1506. \item[0] if \var{S1=S2}.
  1507. \item[>0] if \var{S1>S2}.
  1508. \end{description}
  1509. The comparision of the two strings is case-insensitive.
  1510. The function does not yet take internationalization settings into account.
  1511. \Errors
  1512. None.
  1513. \SeeAlso
  1514. \seef{AnsiCompareText}, \seef{AnsiCompareStr}
  1515. \end{function}
  1516. \latex{\lstinputlisting{sysutex/ex55.pp}}
  1517. \html{\input{sysutex/ex55.tex}}
  1518. \begin{function}{AnsiStrLastChar}
  1519. \Declaration
  1520. function AnsiStrLastChar(Str: PChar): PChar;
  1521. \Declaration
  1522. \var{AnsiStrLastChar} returns a pointer to the last character of \var{Str}.
  1523. Since multibyte characters are not yet supported, this is the same
  1524. as \var{StrEnd(Str)-1}.
  1525. \Errors
  1526. None.
  1527. \SeeAlso
  1528. \seef{AnsiLastChar}
  1529. \end{function}
  1530. \latex{\lstinputlisting{sysutex/ex58.pp}}
  1531. \html{\input{sysutex/ex58.tex}}
  1532. \begin{function}{AnsiStrLComp}
  1533. \Declaration
  1534. Function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1535. \Description
  1536. \var{AnsiStrLComp} compares the first \var{Maxlen} characters of
  1537. 2 \var{PChar} strings, \var{S1} and \var{S2}, and returns the following
  1538. result:
  1539. \begin{description}
  1540. \item[<0] if \var{S1<S2}.
  1541. \item[0] if \var{S1=S2}.
  1542. \item[>0] if \var{S1>S2}.
  1543. \end{description}
  1544. The comparision of the two strings is case-sensitive.
  1545. The function does not yet take internationalization settings into account.
  1546. \Errors
  1547. None.
  1548. \SeeAlso
  1549. \seef{AnsiCompareText}, \seef{AnsiCompareStr}
  1550. \end{function}
  1551. \latex{\lstinputlisting{sysutex/ex56.pp}}
  1552. \html{\input{sysutex/ex56.tex}}
  1553. \begin{function}{AnsiStrLIComp}
  1554. \Declaration
  1555. Function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1556. \Description
  1557. \var{AnsiStrLIComp} compares the first \var{Maxlen} characters of
  1558. 2 \var{PChar} strings, \var{S1} and \var{S2}, and returns the following
  1559. result:
  1560. \begin{description}
  1561. \item[<0] if \var{S1<S2}.
  1562. \item[0] if \var{S1=S2}.
  1563. \item[>0] if \var{S1>S2}.
  1564. \end{description}
  1565. The comparision of the two strings is case-insensitive.
  1566. The function does not yet take internationalization settings into account.
  1567. \Errors
  1568. None.
  1569. \SeeAlso
  1570. \seef{AnsiCompareText}, \seef{AnsiCompareStr}
  1571. \end{function}
  1572. \latex{\lstinputlisting{sysutex/ex57.pp}}
  1573. \html{\input{sysutex/ex57.tex}}
  1574. \begin{function}{AnsiStrLower}
  1575. \Declaration
  1576. Function AnsiStrLower(Str: PChar): PChar;
  1577. \Description
  1578. \var{AnsiStrLower} converts the PChar \var{Str} to lowercase characters
  1579. and returns the resulting pchar. Note that \var{Str} itself is modified,
  1580. not a copy, as in the case of \seef{AnsiLowerCase}.
  1581. It takes into account the operating system language
  1582. settings when doing this, so spcial characters are converted correctly as
  1583. well.
  1584. {\em Remark} On linux, no language setting is taken in account yet.
  1585. \Errors
  1586. None.
  1587. \SeeAlso
  1588. \seef{AnsiStrUpper}, \seef{AnsiLowerCase}
  1589. \end{function}
  1590. \latex{\lstinputlisting{sysutex/ex59.pp}}
  1591. \html{\input{sysutex/ex59.tex}}
  1592. \begin{function}{AnsiStrUpper}
  1593. \Declaration
  1594. Function AnsiStrUpper(Str: PChar): PChar;
  1595. \Description
  1596. \var{AnsiStrUpper} converts the \var{PChar} \var{Str} to uppercase characters
  1597. and returns the resulting string. Note that \var{Str} itself is modified,
  1598. not a copy, as in the case of \seef{AnsiUpperCase}.
  1599. It takes into account the operating system language
  1600. settings when doing this, so spcial characters are converted correctly as
  1601. well.
  1602. {\em Remark} On linux, no language setting is taken in account yet.
  1603. \Errors
  1604. None.
  1605. \SeeAlso
  1606. \seef{AnsiUpperCase}, \seef{AnsiStrLower}, \seef{AnsiLowerCase}
  1607. \end{function}
  1608. \latex{\lstinputlisting{sysutex/ex60.pp}}
  1609. \html{\input{sysutex/ex60.tex}}
  1610. \begin{function}{AnsiUpperCase}
  1611. \Declaration
  1612. Function AnsiUpperCase(const s: string): string;
  1613. \Description
  1614. \var{AnsiUpperCase} converts the string \var{S} to uppercase characters
  1615. and returns the resulting string.
  1616. It takes into account the operating system language
  1617. settings when doing this, so spcial characters are converted correctly as
  1618. well.
  1619. {\em Remark} On linux, no language setting is taken in account yet.
  1620. \Errors
  1621. None.
  1622. \SeeAlso
  1623. \seef{AnsiStrUpper}, \seef{AnsiStrLower}, \seef{AnsiLowerCase}
  1624. \end{function}
  1625. \latex{\lstinputlisting{sysutex/ex61.pp}}
  1626. \html{\input{sysutex/ex61.tex}}
  1627. \begin{procedure}{AppendStr}
  1628. \Declaration
  1629. Procedure AppendStr(var Dest: String; const S: string);
  1630. \Description
  1631. \var{AppendStr} appends \var{S} to Dest.
  1632. This function is provided for Delphi
  1633. compatibility only, since it is completely equivalent to \var{Dest:=Dest+S}.
  1634. \Errors
  1635. None.
  1636. \SeeAlso
  1637. \seep{AssignStr},\seef{NewStr}, \seep{DisposeStr}
  1638. \end{procedure}
  1639. \latex{\lstinputlisting{sysutex/ex62.pp}}
  1640. \html{\input{sysutex/ex62.tex}}
  1641. \begin{procedure}{AssignStr}
  1642. \Declaration
  1643. Procedure AssignStr(var P: PString; const S: string);
  1644. \Description
  1645. \var{AssignStr} allocates \var{S} to P. The old value of \var{P} is
  1646. disposed of.
  1647. This function is provided for Delphi compatibility only. \var{AnsiStrings}
  1648. are managed on the heap and should be preferred to the mechanism of
  1649. dynamically allocated strings.
  1650. \Errors
  1651. None.
  1652. \SeeAlso
  1653. \seef{NewStr}, \seep{AppendStr}, \seep{DisposeStr}
  1654. \end{procedure}
  1655. \latex{\lstinputlisting{sysutex/ex63.pp}}
  1656. \html{\input{sysutex/ex63.tex}}
  1657. \begin{function}{BCDToInt}
  1658. \Declaration
  1659. Function BCDToInt(Value: integer): integer;
  1660. \Description
  1661. \var{BCDToInt} converts a \var{BCD} coded integer to a normal integer.
  1662. \Errors
  1663. None.
  1664. \SeeAlso
  1665. \seef{StrToInt}, \seef{IntToStr}
  1666. \end{function}
  1667. \latex{\lstinputlisting{sysutex/ex64.pp}}
  1668. \html{\input{sysutex/ex64.tex}}
  1669. \begin{function}{CompareMem}
  1670. \Declaration
  1671. Function CompareMem(P1, P2: Pointer; Length: cardinal): integer;
  1672. \Description
  1673. \var{CompareMem} compares, byte by byte, 2 memory areas pointed
  1674. to by \var{P1} and \var{P2}, for a length of \var{L} bytes.
  1675. It returns the following values:
  1676. \begin{description}
  1677. \item[<0] if at some position the byte at \var{P1} is less than the byte at the
  1678. same postion at \var{P2}.
  1679. \item[0] if all \var{L} bytes are the same.
  1680. \item[3]
  1681. \end{description}
  1682. \Errors
  1683. \SeeAlso
  1684. \end{function}
  1685. \begin{function}{CompareStr}
  1686. \Declaration
  1687. Function CompareStr(const S1, S2: string): Integer;
  1688. \Description
  1689. \var{CompareStr} compares two strings, \var{S1} and \var{S2},
  1690. and returns the following
  1691. result:
  1692. \begin{description}
  1693. \item[<0] if \var{S1<S2}.
  1694. \item[0] if \var{S1=S2}.
  1695. \item[>0] if \var{S1>S2}.
  1696. \end{description}
  1697. The comparision of the two strings is case-sensitive.
  1698. The function does not take internationalization settings into account, it
  1699. simply compares ASCII values.
  1700. \Errors
  1701. None.
  1702. \SeeAlso
  1703. \seef{AnsiCompareText}, \seef{AnsiCompareStr}, \seef{CompareText}
  1704. \end{function}
  1705. \latex{\lstinputlisting{sysutex/ex65.pp}}
  1706. \html{\input{sysutex/ex65.tex}}
  1707. \begin{function}{CompareText}
  1708. \Declaration
  1709. Function CompareText(const S1, S2: string): integer;
  1710. \Description
  1711. \var{CompareText} compares two strings, \var{S1} and \var{S2},
  1712. and returns the following
  1713. result:
  1714. \begin{description}
  1715. \item[<0] if \var{S1<S2}.
  1716. \item[0] if \var{S1=S2}.
  1717. \item[>0] if \var{S1>S2}.
  1718. \end{description}
  1719. The comparision of the two strings is case-insensitive.
  1720. The function does not take internationalization settings into account, it
  1721. simply compares ASCII values.
  1722. \Errors
  1723. None.
  1724. \SeeAlso
  1725. \seef{AnsiCompareText}, \seef{AnsiCompareStr}, \seef{CompareStr}
  1726. \end{function}
  1727. \latex{\lstinputlisting{sysutex/ex66.pp}}
  1728. \html{\input{sysutex/ex66.tex}}
  1729. \begin{procedurel}{DisposeStr}{DisposeStrSys}
  1730. \Declaration
  1731. Procedure DisposeStr(S: PString);
  1732. \Description
  1733. \var{DisposeStr} removes the dynamically allocated string \var{S} from the
  1734. heap, and releases the occupied memory.
  1735. This function is provided for Delphi compatibility only. \var{AnsiStrings}
  1736. are managed on the heap and should be preferred to the mechanism of
  1737. dynamically allocated strings.
  1738. \Errors
  1739. None.
  1740. \SeeAlso
  1741. \seef{NewStr}, \seep{AppendStr}, \seep{AssignStr}
  1742. \end{procedurel}
  1743. For an example, see \seep{DisposeStr}.
  1744. \begin{function}{FloatToStr}
  1745. \Declaration
  1746. Function FloatToStr(Value: Extended): String;
  1747. \Description
  1748. \var{FloatToStr} converts the floating point variable \var{Value} to a
  1749. string representation. It will choose the shortest possible notation of the
  1750. two following formats:
  1751. \begin{description}
  1752. \item[Fixed format] will represent the string in fixed notation,
  1753. \item[Decimal format] will represent the string in scientific notation.
  1754. \end{description}
  1755. (more information on these formats can be found in \seef{FloatToStrF})
  1756. \var{FloatToStr} is completely equivalent to a \var{FloatToStrF(Value, ffGeneral,
  1757. 15, 0);} call.
  1758. \Errors
  1759. None.
  1760. \SeeAlso
  1761. \seef{FloatToStrF}
  1762. %, \seef{FormatFloat}
  1763. \end{function}
  1764. \latex{\lstinputlisting{sysutex/ex67.pp}}
  1765. \html{\input{sysutex/ex67.tex}}
  1766. \begin{function}{FloatToStrF}
  1767. \Declaration
  1768. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  1769. \Description
  1770. \var{FloatToStrF} converts the floating point number \var{value} to a string
  1771. representation, according to the settings of the parameters \var{Format},
  1772. \var{Precision} and \var{Digits}.
  1773. The meaning of the \var{Precision} and \var{Digits} parameter depends on the
  1774. \var{Format} parameter. The format is controlled mainly by the \var{Format}
  1775. parameter. It can have one of the following values:
  1776. \begin{description}
  1777. \item[ffcurrency] Money format. \var{Value} is converted to a string using
  1778. the global variables \var{CurrencyString}, \var{CurrencyFormat} and
  1779. \var{NegCurrencyFormat}. The \var{Digits} paramater specifies the number of digits
  1780. following the decimal point and should be in the range -1 to 18. If Digits
  1781. equals \var{-1}, \var{CurrencyDecimals} is assumed. The \var{Precision} parameter is ignored.
  1782. %
  1783. \item[ffExponent] Scientific format. \var{Value} is converted to a
  1784. string using scientific notation: 1 digit before the decimal point, possibly
  1785. preceded by a minus sign if \var{Value} is negative. The number of
  1786. digits after the decimal point is controlled by \var{Precision} and must lie
  1787. in the range 0 to 15.
  1788. %
  1789. \item[ffFixed] Fixed point format. \var{Value} is converted to a string
  1790. using fixed point notation. The result is composed of all digits of the
  1791. integer part of \var{Value}, preceded by a minus sign if \var{Value} is
  1792. negative. Following the integer part is \var{DecimalSeparator} and then the
  1793. fractional part of \var{Value}, rounded off to \var{Digits} numbers.
  1794. If the number is too large then the result will be in scientific notation.
  1795. %
  1796. \item[ffGeneral] General number format. The argument is converted to a
  1797. string using \var{ffExponent} or \var{ffFixed} format, depending on wich one
  1798. gives the shortest string. There will be no trailing zeroes. If \var{Value}
  1799. is less than \var{0.00001} or if the number of decimals left of the decimal
  1800. point is larger than \var{Precision} then scientific notation is used, and
  1801. \var{Digits} is the minimum number of digits in the exponent. Otherwise
  1802. \var{Digits} is ignored.
  1803. \item[ffnumber] Is the same as \var{ffFixed}, except that thousand separators
  1804. are inserted in the resultig string.
  1805. \end{description}
  1806. \Errors
  1807. None.
  1808. \SeeAlso
  1809. \seef{FloatToStr}, \seef{FloatToText}
  1810. \end{function}
  1811. \latex{\lstinputlisting{sysutex/ex68.pp}}
  1812. \html{\input{sysutex/ex68.tex}}
  1813. \begin{function}{FloatToText}
  1814. \Declaration
  1815. Function FloatToText(Buffer : Pchar;Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): Longint;
  1816. \Description
  1817. \var{FloatToText} converts the floating point variable \var{Value} to a
  1818. string representation and stores it in \var{Buffer}. The conversion is
  1819. giverned by \var{format}, \var{Precisison} and \var{Digits}.
  1820. more information on these parameters can be found in \seef{FloatToStrF}.
  1821. \var{Buffer} should point to enough space to hold the result. No checking on
  1822. this is performed.
  1823. The result is the number of characters that was copied in \var{Buffer}.
  1824. \Errors
  1825. None.
  1826. \SeeAlso
  1827. \seef{FloatToStr}, \seef{FloatToStrF}
  1828. \end{function}
  1829. \latex{\lstinputlisting{sysutex/ex69.pp}}
  1830. \html{\input{sysutex/ex69.tex}}
  1831. \begin{procedure}{FmtStr}
  1832. \Declaration
  1833. Procedure (Var Res: String; Const Fmt : String; Const args: Array of const);
  1834. \Description
  1835. \var{FmtStr} calls \seef{Format} with \var{Fmt} and \var{Args} as arguments,
  1836. and stores the result in \var{Res}. For more information on how the
  1837. resulting string is composed, see \seef{Format}.
  1838. \Errors
  1839. In case of error, a \var{EConvertError} exception is raised.
  1840. \SeeAlso
  1841. \seef{Format}, \seef{FormatBuf}.
  1842. \end{procedure}
  1843. \latex{\lstinputlisting{sysutex/ex70.pp}}
  1844. \html{\input{sysutex/ex70.tex}}
  1845. \begin{function}{Format}
  1846. \Declaration
  1847. Function Format(Const Fmt : String; const Args : Array of const) : String;
  1848. \Description
  1849. Format replaces all placeholders in\var{Fmt} with the arguments passed in
  1850. \var{Args} and returns the resulting string. A placeholder looks as follows:
  1851. \begin{verbatim}
  1852. '%' [Index':'] ['-'] [Width] ['.' Precision] ArgType
  1853. \end{verbatim}
  1854. elements between single quotes must be typed as shown without the quotes,
  1855. and elements between square brackets \var{[ ]} are optional. The meaning
  1856. of the different elements is shown below:
  1857. \begin{description}
  1858. \item['\%'] starts the placeholder. If you want to insert a literal
  1859. \var{\%} character, then you must insert two of them : \var{\%\%}.
  1860. \item[Index ':'] takes the \var{Index}-th element in the argument array
  1861. as the element to insert.
  1862. \item['-'] tells \var{Format} to left-align the inserted text. The default
  1863. behaviour is to right-align inserted text. This can only take effect if the
  1864. \var{Width} element is also specified.
  1865. \item[Width] the inserted string must have at least have \var{Width}
  1866. characters. If not, the inserted string will be padded with spaces. By
  1867. default, the string is left-padded, resulting in a right-aligned string.
  1868. This behaviour can be changed by the \var{'-'} character.
  1869. \item['.' Precision] Indicates the precision to be used when converting
  1870. the argument. The exact meaning of this parameter depends on \var{ArgType}.
  1871. \end{description}
  1872. The \var{Index}, \var{Width} and \var{Precision} parameters can be replaced
  1873. by \var{*}, in which case their value will be read from the next element in
  1874. the \var{Args} array. This value must be an integer, or an
  1875. \var{EConvertError} exception will be raised.
  1876. The argument type is determined from \var{ArgType}. It can have one of the
  1877. following values (case insensitive):
  1878. \begin{description}
  1879. \item[D] Decimal format. The next argument in the \var{Args} array should be
  1880. an integer. The argument is converted to a decimal string,. If precision is
  1881. specified, then the string will have at least \var{Precision} digits in it.
  1882. If needed, the string is (left) padded with zeroes.
  1883. \item[E] scientific format. The next argument in the \var{Args} array should
  1884. be a Floating point value. The argument is converted to a decimal string
  1885. using scientific notation, using \seef{FloatToStrF}, where the optional
  1886. precision is used to specify the total number of decimals. (defalt a valueof
  1887. 15 is used). The exponent is formatted using maximally 3 digits.
  1888. In short, the \var{E} specifier formats it's arguument as follows:
  1889. \begin{verbatim}
  1890. FloatToStrF(Argument,ffexponent,Precision,3)
  1891. \end{verbatim}
  1892. \item[F] fixed point format. The next argument in the \var{Args} array
  1893. should be a floating point value. The argument is converted to a
  1894. decimal string, using fixed notation (see \seef{FloatToStrF}).
  1895. \var{Precision} indicates the number of digits following the
  1896. decimal point.
  1897. In short, the \var{F} specifier formats it's arguument as follows:
  1898. \begin{verbatim}
  1899. FloatToStrF(Argument,ffFixed,ffixed,9999,Precision)
  1900. \end{verbatim}
  1901. \item[G] General number format. The next argument in the \var{Args} array
  1902. should be a floating point value. The argument is converted to a decimal
  1903. string using fixed point notation or scientific notation, depending on which
  1904. gives the shortest result. \var{Precision} is used to determine the number
  1905. of digits after the decimal point.
  1906. In short, the \var{G} specifier formats it's arguument as follows:
  1907. \begin{verbatim}
  1908. FloatToStrF(Argument,ffGeneral,Precision,3)
  1909. \end{verbatim}
  1910. \item[M] Currency format. the next argument in the var{Args} array must
  1911. be a floating point value. The argument is converted to a decimal string
  1912. using currency notation. This means that fixed-point notation is used, but
  1913. that the currency symbol is appended. If precision is specified, then
  1914. then it overrides the \var{CurrencyDecimals} global variable used in the
  1915. \seef{FloatToStrF}
  1916. In short, the \var{M} specifier formats it's arguument as follows:
  1917. \begin{verbatim}
  1918. FloatToStrF(Argument,ffCurrency,9999,Precision)
  1919. \end{verbatim}
  1920. \item[N] Number format. This is the same as fixed point format, except that
  1921. thousand separators are inserted in the resulting string.
  1922. \item[P] Pointer format. The next argument in the \var{Args} array must be a
  1923. pointer (typed or untyped). The pointer value is converted to a string of
  1924. length 8, representing the hexadecimal value of the pointer.
  1925. \item[S] String format. The next argument in the \var{Args} array must be
  1926. a string. The argument is simply copied to the result string. If
  1927. \var{Precision} is specified, then only \var{Precision} characters are
  1928. copied to the result string.
  1929. \item[X] hexadecimal format. The next argument in the \var{Args} array must
  1930. be an integer. The argument is converted to a hexadecimal string with just
  1931. enough characters to contain the value of the integer. If \var{Precision}
  1932. is specified then the resulting hexadecimal representation will have at
  1933. least \var{Precision} characters in it (with a maximum value of 32).
  1934. \end{description}
  1935. \Errors
  1936. In case of error, an \var{EConversionError} exception is raised. Possible
  1937. errors are:
  1938. \begin{enumerate}
  1939. \item Errors in the format specifiers.
  1940. \item The next argument is not of the type needed by a specifier.
  1941. \item The number of arguments is not sufficient for all format specifiers.
  1942. \end{enumerate}
  1943. \SeeAlso
  1944. \seef{FormatBuf}
  1945. \end{function}
  1946. \latex{\lstinputlisting{sysutex/ex71.pp}}
  1947. \html{\input{sysutex/ex71.tex}}
  1948. \begin{function}{FormatBuf}
  1949. \Declaration
  1950. Function FormatBuf(Var Buffer; BufLen : Cardinal; Const Fmt; fmtLen : Cardinal; Const Args : Array of const) : Cardinal;
  1951. \Description
  1952. \var{Format}
  1953. \Errors
  1954. \SeeAlso
  1955. \end{function}
  1956. \latex{\lstinputlisting{sysutex/ex72.pp}}
  1957. \html{\input{sysutex/ex72.tex}}
  1958. \begin{function}{IntToHex}
  1959. \Declaration
  1960. Function IntToHex(Value: integer; Digits: integer): string;
  1961. \Description
  1962. \var{IntToHex} converts \var{Value} to a hexadecimal string
  1963. representation. The result will contain at least \var{Digits}
  1964. characters. If \var{Digits} is less than the needed number of characters,
  1965. the string will NOT be truncated. If \var{Digits} is larger than the needed
  1966. number of characters, the result is padded with zeroes.
  1967. \Errors
  1968. None.
  1969. \SeeAlso
  1970. \seef{IntToStr}, \var{StrToInt}
  1971. \end{function}
  1972. \latex{\lstinputlisting{sysutex/ex73.pp}}
  1973. \html{\input{sysutex/ex73.tex}}
  1974. \begin{function}{IntToStr}
  1975. \Declaration
  1976. Function IntToStr(Value: integer): string;
  1977. \Description
  1978. \var{IntToStr} coverts \var{Value} to it's string representation.
  1979. The resulting string has only as much characters as needed to represent
  1980. the value. If the value is negative a minus sign is prepended to the
  1981. string.
  1982. \Errors
  1983. None.
  1984. \SeeAlso
  1985. \seef{IntToHex}, \seef{StrToInt}
  1986. \end{function}
  1987. \latex{\lstinputlisting{sysutex/ex74.pp}}
  1988. \html{\input{sysutex/ex74.tex}}
  1989. \begin{function}{IsValidIdent}
  1990. \Declaration
  1991. Function IsValidIdent(const Ident: string): boolean;
  1992. \Description
  1993. \var{IsValidIdent} returns \var{True} if \var{Ident} can be used as a
  1994. compoent name. It returns \var{False} otherwise. \var{Ident} must consist of
  1995. a letter or underscore, followed by a combination of letters, numbers or
  1996. underscores to be a valid identifier.
  1997. \Errors
  1998. None.
  1999. \SeeAlso
  2000. \end{function}
  2001. \latex{\lstinputlisting{sysutex/ex75.pp}}
  2002. \html{\input{sysutex/ex75.tex}}
  2003. \begin{function}{LeftStr}
  2004. \Declaration
  2005. Function LeftStr(const S: string; Count: integer): string;
  2006. \Description
  2007. \var{LeftStr} returns the \var{Count} leftmost characters of \var{S}.
  2008. It is equivalent to a call to \var{Copy(S,1,Count)}.
  2009. \Errors
  2010. None.
  2011. \SeeAlso
  2012. \seef{RightStr}, \seef{TrimLeft}, \seef{TrimRight}, \seef{Trim}
  2013. \end{function}
  2014. \latex{\lstinputlisting{sysutex/ex76.pp}}
  2015. \html{\input{sysutex/ex76.tex}}
  2016. \begin{function}{LoadStr}
  2017. \Declaration
  2018. Function LoadStr(Ident: integer): string;
  2019. \Description
  2020. This function is not yet implemented. resources are not yet supported.
  2021. \Errors
  2022. \SeeAlso
  2023. \end{function}
  2024. \begin{function}{LowerCase}
  2025. \Declaration
  2026. Function LowerCase(const s: string): string;
  2027. \Description
  2028. \var{LowerCase} returns the lowercase equivalent of \var{S}. Ansi characters
  2029. are not taken into account, only ASCII codes below 127 are converted. It is
  2030. completely equivalent to the lowercase function of the system unit, and is
  2031. provided for compatiibility only.
  2032. \Errors
  2033. None.
  2034. \SeeAlso
  2035. \seef{AnsiLowerCase}, \seef{UpperCase}, \seef{AnsiUpperCase}
  2036. \end{function}
  2037. \latex{\lstinputlisting{sysutex/ex77.pp}}
  2038. \html{\input{sysutex/ex77.tex}}
  2039. \begin{functionl}{NewStr}{NewStrSys}
  2040. \Declaration
  2041. Function NewStr(const S: string): PString;
  2042. \Description
  2043. \var{NewStr} assigns a new dynamic string on the heap, copies \var{S} into
  2044. it, and returns a pointer to the newly assigned string.
  2045. This function is obsolete, and shouldn't be used any more. The
  2046. \var{AnsiString} mechanism also allocates ansistrings on the heap, and
  2047. should be preferred over this mechanism.
  2048. \Errors
  2049. If not enough memory is present, an EOutOfMemory exception will be raised.
  2050. \SeeAlso
  2051. \seep{AssignStr}, \seepl{DisposeStr}{DisposeStrSys}
  2052. \end{functionl}
  2053. For an example, see \seep{AssignStr}.
  2054. \begin{function}{QuotedStr}
  2055. \Declaration
  2056. Function QuotedStr(const S: string): string;
  2057. \Description
  2058. \var{QuotedStr} returns the string \var{S}, quoted with single quotes. This means
  2059. that \var{S} is enclosed in single quotes, and every single quote in \var{S}
  2060. is doubled. It is equivalent to a call to \var{AnsiQuotedStr(s, '''')}.
  2061. \Errors
  2062. None.
  2063. \SeeAlso
  2064. \seef{AnsiQuotedStr}, \seef{AnsiExtractQuotedStr}.
  2065. \end{function}
  2066. \latex{\lstinputlisting{sysutex/ex78.pp}}
  2067. \html{\input{sysutex/ex78.tex}}
  2068. \begin{function}{RightStr}
  2069. \Declaration
  2070. Function RightStr(const S: string; Count: integer): string;
  2071. \Description
  2072. \var{RightStr} returns the \var{Count} rightmost characters of \var{S}.
  2073. It is equivalent to a call to \var{Copy(S,Length(S)+1-Count,Count)}.
  2074. If \var{Count} is larger than the actual length of \var{S} only the real
  2075. length will be used.
  2076. \Errors
  2077. None.
  2078. \SeeAlso
  2079. \seef{LeftStr},\seef{Trim}, \seef{TrimLeft}, \seef{TrimRight}
  2080. \end{function}
  2081. \latex{\lstinputlisting{sysutex/ex79.pp}}
  2082. \html{\input{sysutex/ex79.tex}}
  2083. \begin{function}{StrFmt}
  2084. \Declaration
  2085. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  2086. \Description
  2087. \var{StrFmt} will format \var{fmt} with \var{Args}, as the \seef{Format}
  2088. function does, and it will store the result in \var{Buffer}. The function
  2089. returns \var{Buffer}. \var{Buffer} should point to enough space to contain
  2090. the whole result.
  2091. \Errors
  2092. for a list of errors, see \seef{Format}.
  2093. \SeeAlso
  2094. \seef{StrLFmt}, \seep{FmtStr}, \seef{Format}, \seef{FormatBuf}
  2095. \end{function}
  2096. \latex{\lstinputlisting{sysutex/ex80.pp}}
  2097. \html{\input{sysutex/ex80.tex}}
  2098. \begin{function}{StrLFmt}
  2099. \Declaration
  2100. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  2101. \Description
  2102. \var{StrLFmt} will format \var{fmt} with \var{Args}, as the \seef{Format}
  2103. function does, and it will store maximally \var{Maxlen characters} of the
  2104. result in \var{Buffer}. The function returns \var{Buffer}. \var{Buffer}
  2105. should point to enough space to contain \var{MaxLen} characters.
  2106. \Errors
  2107. for a list of errors, see \seef{Format}.
  2108. \SeeAlso
  2109. \seef{StrFmt}, \seep{FmtStr}, \seef{Format}, \seef{FormatBuf}
  2110. \end{function}
  2111. \latex{\lstinputlisting{sysutex/ex81.pp}}
  2112. \html{\input{sysutex/ex81.tex}}
  2113. \begin{function}{StrToInt}
  2114. \Declaration
  2115. Function StrToInt(const s: string): integer;
  2116. \Description
  2117. \var{StrToInt} will convert the string \var{S}to an integer.
  2118. If the string contains invalid characters or has an invalid format,
  2119. then an \var{EConvertError} is raised.
  2120. To be successfully converted, a string can contain a combination
  2121. of \var{numerical} characters, possibly preceded by a minus sign (\var{-}).
  2122. Spaces are not allowed.
  2123. \Errors
  2124. In case of error, an \var{EConvertError} is raised.
  2125. \SeeAlso
  2126. \seef{IntToStr}, \seef{StrToIntDef}
  2127. \end{function}
  2128. \latex{\lstinputlisting{sysutex/ex82.pp}}
  2129. \html{\input{sysutex/ex82.tex}}
  2130. \begin{function}{StrToIntDef}
  2131. \Declaration
  2132. Function StrToIntDef(const S: string; Default: integer): integer;
  2133. \Description
  2134. \var{StrToIntDef} will convert a string to an integer. If the string contains
  2135. invalid characters or has an invalid format, then \var{Default} is returned.
  2136. To be successfully converted, a string can contain a combination of
  2137. \var{numerical} characters, possibly preceded by a minus sign (\var{-}).
  2138. Spaces are not allowed.
  2139. \Errors
  2140. None.
  2141. \SeeAlso
  2142. \seef{IntToStr}, \seef{StrToInt}
  2143. \end{function}
  2144. \latex{\lstinputlisting{sysutex/ex83.pp}}
  2145. \html{\input{sysutex/ex83.tex}}
  2146. \begin{function}{Trim}
  2147. \Declaration
  2148. Function Trim(const S: string): string;
  2149. \Description
  2150. \var{Trim} strips blank characters (spaces) at the beginning and end of \var{S}
  2151. and returns the resulting string. Only \var{\#32} characters are stripped.
  2152. If the string contains only spaces, an empty string is returned.
  2153. \Errors
  2154. None.
  2155. \SeeAlso
  2156. \seef{TrimLeft}, \seef{TrimRight}
  2157. \end{function}
  2158. \latex{\lstinputlisting{sysutex/ex84.pp}}
  2159. \html{\input{sysutex/ex84.tex}}
  2160. \begin{function}{TrimLeft}
  2161. \Declaration
  2162. Function TrimLeft(const S: string): string;
  2163. \Description
  2164. \var{TrimLeft} strips blank characters (spaces) at the beginning of \var{S}
  2165. and returns the resulting string. Only \var{\#32} characters are stripped.
  2166. If the string contains only spaces, an empty string is returned.
  2167. \Errors
  2168. None.
  2169. \SeeAlso
  2170. \seef{Trim}, \seef{TrimRight}
  2171. \end{function}
  2172. \latex{\lstinputlisting{sysutex/ex85.pp}}
  2173. \html{\input{sysutex/ex85.tex}}
  2174. \begin{function}{TrimRight}
  2175. \Declaration
  2176. Function TrimRight(const S: string): string;
  2177. \Description
  2178. \var{Trim} strips blank characters (spaces) at the end of \var{S}
  2179. and returns the resulting string. Only \var{\#32} characters are stripped.
  2180. If the string contains only spaces, an empty string is returned.
  2181. \Errors
  2182. None.
  2183. \SeeAlso
  2184. \seef{Trim}, \seef{TrimLeft}
  2185. \end{function}
  2186. \latex{\lstinputlisting{sysutex/ex86.pp}}
  2187. \html{\input{sysutex/ex86.tex}}
  2188. \begin{function}{UpperCase}
  2189. \Declaration
  2190. Function UpperCase(const s: string): string;
  2191. \Description
  2192. \var{UpperCase} returns the uppercase equivalent of \var{S}. Ansi characters
  2193. are not taken into account, only ASCII codes below 127 are converted. It is
  2194. completely equivalent to the \var{UpCase} function of the system unit, and is
  2195. provided for compatiibility only.
  2196. \Errors
  2197. None.
  2198. \SeeAlso
  2199. \seef{AnsiLowerCase}, \seef{LowerCase}, \seef{AnsiUpperCase}
  2200. \Errors
  2201. \SeeAlso
  2202. \end{function}
  2203. \latex{\lstinputlisting{sysutex/ex87.pp}}
  2204. \html{\input{sysutex/ex87.tex}}