sysutils.tex 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  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 \seep{FindClose} 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 variables are used in the case translation routines.
  88. \begin{verbatim}
  89. type
  90. TCaseTranslationTable = array[0..255] of char;
  91. var
  92. UpperCaseTable: TCaseTranslationTable;
  93. LowerCaseTable: TCaseTranslationTable;
  94. \end{verbatim}
  95. The initialization code of the \file{sysutils} unit fills these
  96. tables with the appropriate values. For the win32 and go32v2
  97. versions, this information is obtained from the operating system.
  98. The following constants control the formatting of dates.
  99. For the Win32 version of the \file{sysutils} unit, these
  100. constants are set according to the internationalization
  101. settings of Windows by the initialization code of the unit.
  102. \begin{verbatim}
  103. Const
  104. DateSeparator: char = '-';
  105. ShortDateFormat: string = 'd/m/y';
  106. LongDateFormat: string = 'dd" "mmmm" "yyyy';
  107. ShortMonthNames: array[1..12] of string[128] =
  108. ('Jan','Feb','Mar','Apr','May','Jun',
  109. 'Jul','Aug','Sep','Oct','Nov','Dec');
  110. LongMonthNames: array[1..12] of string[128] =
  111. ('January','February','March','April',
  112. 'May','June','July','August',
  113. 'September','October','November','December');
  114. ShortDayNames: array[1..7] of string[128] =
  115. ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  116. LongDayNames: array[1..7] of string[128] =
  117. ('Sunday','Monday','Tuesday','Wednesday',
  118. 'Thursday','Friday','Saturday');
  119. \end{verbatim}
  120. The following constants control the formatting of times.
  121. For the Win32 version of the \file{sysutils} unit, these
  122. constants are set according to the internationalization
  123. settings of Windows by the initialization code of the unit.
  124. \begin{verbatim}
  125. Const
  126. ShortTimeFormat: string = 'hh:nn';
  127. LongTimeFormat: string = 'hh:nn:ss';
  128. TimeSeparator: char = ':';
  129. TimeAMString: string[7] = 'AM';
  130. TimePMString: string[7] = 'PM';
  131. \end{verbatim}
  132. The following constants control the formatting of currencies
  133. and numbers. For the Win32 version of the \file{sysutils} unit,
  134. these constants are set according to the internationalization
  135. settings of Windows by the initialization code of the unit.
  136. \begin{verbatim}
  137. Const
  138. DecimalSeparator : Char = '.';
  139. ThousandSeparator : Char = ',';
  140. CurrencyDecimals : Byte = 2;
  141. CurrencyString : String[7] = '$';
  142. { Format to use when formatting currency :
  143. 0 = $1 1 = 1$ 2 = $ 1 3 = 1 $
  144. 4 = Currency string replaces decimal indicator.
  145. e.g. 1$50
  146. }
  147. CurrencyFormat : Byte = 1;
  148. { Same as above, only for negative currencies:
  149. 0 = ($1)
  150. 1 = -$1
  151. 2 = $-1
  152. 3 = $1-
  153. 4 = (1$)
  154. 5 = -1$
  155. 6 = 1-$
  156. 7 = 1$-
  157. 8 = -1 $
  158. 9 = -$ 1
  159. 10 = $ 1-
  160. }
  161. NegCurrFormat : Byte = 5;
  162. \end{verbatim}
  163. The following types are used in various string functions.
  164. \begin{verbatim}
  165. type
  166. PString = ^String;
  167. TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
  168. \end{verbatim}
  169. The following constants are used in the file name handling routines. Do not
  170. use a slash of backslash character directly as a path separator; instead
  171. use the \var{OsDirSeparator} character.
  172. \begin{verbatim}
  173. Const
  174. DirSeparators : set of char = ['/','\'];
  175. {$ifdef Linux}
  176. OSDirSeparator = '/';
  177. {$else}
  178. OsDirSeparator = '\';
  179. {$endif}
  180. \end{verbatim}
  181. \section{Date and time functions}
  182. \subsection{Date and time formatting characters}
  183. \label{se:formatchars}
  184. Various date and time formatting routines accept a format string.
  185. to format the date and or time. The following characters can be used
  186. to control the date and time formatting:
  187. \begin{description}
  188. \item[c] : shortdateformat + ' ' + shorttimeformat
  189. \item[d] : day of month
  190. \item[dd] : day of month (leading zero)
  191. \item[ddd] : day of week (abbreviation)
  192. \item[dddd] : day of week (full)
  193. \item[ddddd] : shortdateformat
  194. \item[dddddd] : longdateformat
  195. \item[m] : month
  196. \item[mm] : month (leading zero)
  197. \item[mmm] : month (abbreviation)
  198. \item[mmmm] : month (full)
  199. \item[y] : year (four digits)
  200. \item[yy] : year (two digits)
  201. \item[yyyy] : year (with century)
  202. \item[h] : hour
  203. \item[hh] : hour (leading zero)
  204. \item[n] : minute
  205. \item[nn] : minute (leading zero)
  206. \item[s] : second
  207. \item[ss] : second (leading zero)
  208. \item[t] : shorttimeformat
  209. \item[tt] : longtimeformat
  210. \item[am/pm] : use 12 hour clock and display am and pm accordingly
  211. \item[a/p] : use 12 hour clock and display a and p accordingly
  212. \item[/] : insert date seperator
  213. \item[:] : insert time seperator
  214. \item["xx"] : literal text
  215. \item['xx'] : literal text
  216. \end{description}
  217. \begin{type}{TDateTime}
  218. \Declaration
  219. TDateTime = Double;
  220. \Description
  221. Many functions return or require a \var{TDateTime} type, which contains
  222. a date and time in encoded form. The date and time are converted to a double
  223. as follows:
  224. \end{type}
  225. \begin{function}{Date}
  226. \Declaration
  227. Function Date: TDateTime;
  228. \Description
  229. \var{Date} returns the current date in \var{TDateTime} format.
  230. For more information about the \var{TDateTime} type, see \seety{TDateTime}.
  231. \Errors
  232. None.
  233. \SeeAlso
  234. \seef{Time},\seef{Now}, \seety{TDateTime}.
  235. \end{function}
  236. \latex{\inputlisting{sysutex/ex1.pp}}
  237. \html{\input{sysutex/ex1.tex}}
  238. \begin{function}{DateTimeToFileDate}
  239. \Declaration
  240. Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
  241. \Description
  242. \var{DateTimeToFileDate} function converts a date/time indication in
  243. \var{TDateTime} format to a filedate function, such as returned for
  244. instance by the \seef{FileAge} function.
  245. \Errors
  246. None.
  247. \SeeAlso
  248. \seef{Time}, \seef{Date}, \seef{FileDateToDateTime},
  249. \seep{DateTimeToSystemTime}, \seef{DateTimeToTimeStamp}
  250. \end{function}
  251. \latex{\inputlisting{sysutex/ex2.pp}}
  252. \html{\input{sysutex/ex2.tex}}
  253. \begin{function}{DateTimeToStr}
  254. \Declaration
  255. Function DateTimeToStr(DateTime: TDateTime): string;
  256. \Description
  257. \var{DateTimeToStr} returns a string representation of
  258. \var{DateTime} using the formatting specified in
  259. \var{ShortDateTimeFormat}. It corresponds to a call to
  260. \var{FormatDateTime('c',DateTime)} (see \sees{formatchars}).
  261. \Errors
  262. None.
  263. \SeeAlso
  264. \seef{FormatDateTime}, \seety{TDateTime}.
  265. \end{function}
  266. \latex{\inputlisting{sysutex/ex3.pp}}
  267. \html{\input{sysutex/ex3.tex}}
  268. \begin{procedure}{DateTimeToString}
  269. \Declaration
  270. Procedure DateTimeToString(var Result: string; const FormatStr: string; const DateTime: TDateTime);
  271. \Description
  272. \var{DateTimeToString} returns in \var{Result} a string representation of
  273. \var{DateTime} using the formatting specified in \var{FormatStr}.
  274. for a list of characters that can be used in the \var{FormatStr} formatting
  275. string, see \sees{formatchars}.
  276. \Errors
  277. In case a wrong formatting character is found, an \var{EConvertError} is
  278. raised.
  279. \SeeAlso
  280. \seef{FormatDateTime}, \sees{formatchars}.
  281. \end{procedure}
  282. \latex{\inputlisting{sysutex/ex4.pp}}
  283. \html{\input{sysutex/ex4.tex}}
  284. \begin{procedure}{DateTimeToSystemTime}
  285. \Declaration
  286. Procedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);
  287. \Description
  288. \var{DateTimeToSystemTime} converts a date/time pair in \var{DateTime}, with
  289. \var{TDateTime} format to a system time \var{SystemTime}.
  290. \Errors
  291. None.
  292. \SeeAlso
  293. \seef{DateTimeToFileDate}, \seef{SystemTimeToDateTime},
  294. \seef{DateTimeToTimeStamp}
  295. \end{procedure}
  296. \latex{\inputlisting{sysutex/ex5.pp}}
  297. \html{\input{sysutex/ex5.tex}}
  298. \begin{function}{DateTimeToTimeStamp}
  299. \Declaration
  300. Function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
  301. \Description
  302. \var{DateTimeToSystemTime} converts a date/time pair in \var{DateTime}, with
  303. \var{TDateTime} format to a \var{TTimeStamp} format.
  304. \Errors
  305. None.
  306. \SeeAlso
  307. \seef{DateTimeToFileDate}, \seef{SystemTimeToDateTime},
  308. \seep{DateTimeToSystemTime}
  309. \end{function}
  310. \latex{\inputlisting{sysutex/ex6.pp}}
  311. \html{\input{sysutex/ex6.tex}}
  312. \begin{function}{DateToStr}
  313. \Declaration
  314. Function DateToStr(Date: TDateTime): string;
  315. \Description
  316. \var{DateToStr} converts \var{Date} to a string representation. It uses
  317. \var{ShortDateFormat} as it's formatting string. It is hence completely
  318. equivalent to a \var{FormatDateTime('ddddd', Date)}.
  319. \Errors
  320. None.
  321. \SeeAlso
  322. \seef{TimeToStr}, \seef{DateTimeToStr}, \seef{FormatDateTime},
  323. \seef{StrToDate}
  324. \end{function}
  325. \latex{\inputlisting{sysutex/ex7.pp}}
  326. \html{\input{sysutex/ex7.tex}}
  327. \begin{function}{DayOfWeek}
  328. \Declaration
  329. Function DayOfWeek(DateTime: TDateTime): integer;
  330. \Description
  331. \var{DayOfWeek} returns the day of the week from \var{DateTime}.
  332. \var{Sunday} is counted as day 1, \var{Saturday} is counted as
  333. day 7. The result of \var{DayOfWeek} can serve as an index to
  334. the \var{LongDayNames} constant array, to retrieve the name of
  335. the day.
  336. \Errors
  337. None.
  338. \SeeAlso
  339. \seef{Date}, \seef{DateToStr}
  340. \end{function}
  341. \latex{\inputlisting{sysutex/ex8.pp}}
  342. \html{\input{sysutex/ex8.tex}}
  343. \begin{procedure}{DecodeDate}
  344. \Declaration
  345. Procedure DecodeDate(Date: TDateTime; var Year, Month, Day: word);
  346. \Description
  347. \var{DecodeDate} decodes the Year, Month and Day stored in \var{Date},
  348. and returns them in the \var{Year}, \var{Month} and \var{Day} variables.
  349. \Errors
  350. None.
  351. \SeeAlso
  352. \seef{EncodeDate}, \seep{DecodeTime}.
  353. \end{procedure}
  354. \latex{\inputlisting{sysutex/ex9.pp}}
  355. \html{\input{sysutex/ex9.tex}}
  356. \begin{procedure}{DecodeTime}
  357. \Declaration
  358. Procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
  359. \Description
  360. \var{DecodeDate} decodes the hours, minutes, second and milliseconds stored
  361. in \var{Time}, and returns them in the \var{Hour}, \var{Minute} and
  362. \var{Second} and \var{MilliSecond} variables.
  363. \Errors
  364. None.
  365. \SeeAlso
  366. \seef{EncodeTime}, \seep{DecodeDate}.
  367. \end{procedure}
  368. \latex{\inputlisting{sysutex/ex10.pp}}
  369. \html{\input{sysutex/ex10.tex}}
  370. \begin{function}{EncodeDate}
  371. \Declaration
  372. Function EncodeDate(Year, Month, Day :word): TDateTime;
  373. \Description
  374. \var{EncodeDate} encodes the \var{Year}, \var{Month} and \var{Day} variables to
  375. a date in \var{TDateTime} format. It does the opposite of the
  376. \seep{DecodeDate} procedure.
  377. The parameters must lie withing valid ranges (boundaries included):
  378. \begin{description}
  379. \item[Year] must be between 1 and 9999.
  380. \item[Month] must be within the range 1-12.
  381. \item[Day] msut be between 1 and 31.
  382. \end{description}
  383. \Errors
  384. In case one of the parameters is out of it's valid range, 0 is returned.
  385. \SeeAlso
  386. \seef{EncodeTime}, \seep{DecodeDate}.
  387. \end{function}
  388. \latex{\inputlisting{sysutex/ex11.pp}}
  389. \html{\input{sysutex/ex11.tex}}
  390. \begin{function}{EncodeTime}
  391. \Declaration
  392. Function EncodeTime(Hour, Minute, Second, MilliSecond:word): TDateTime;
  393. \Description
  394. \var{EncodeTime} encodes the \var{Hour}, \var{Minute}, \var{Second},
  395. \var{MilliSecond} variables to a \var{TDateTime} format result.
  396. It does the opposite of the \seep{DecodeTime} procedure.
  397. The parameters must have a valid range (boundaries included):
  398. \begin{description}
  399. \item[Hour] must be between 0 and 23.
  400. \item[Minute,second] must both be between 0 and 59.
  401. \item[Millisecond] must be between 0 and 999.
  402. \end{description}
  403. \Errors
  404. In case one of the parameters is outside of it's valid range, 0 is returned.
  405. \SeeAlso
  406. \seef{EncodeDate}, \seep{DecodeTime}.
  407. \end{function}
  408. \latex{\inputlisting{sysutex/ex12.pp}}
  409. \html{\input{sysutex/ex12.tex}}
  410. \begin{function}{FileDateToDateTime}
  411. \Declaration
  412. Function FileDateToDateTime(Filedate : Longint) : TDateTime;
  413. \Description
  414. \var{FileDateToDateTime} converts the date/time encoded in \var{filedate}
  415. to a \var{TDateTime} encoded form. It can be used to convert date/time values
  416. returned by the \seef{FileAge} or \seef{FindFirst}/\seef{FindNext}
  417. functions to \var{TDateTime} form.
  418. \Errors
  419. None.
  420. \SeeAlso
  421. \seef{DateTimeToFileDate}
  422. \end{function}
  423. \latex{\inputlisting{sysutex/ex13.pp}}
  424. \html{\input{sysutex/ex13.tex}}
  425. \begin{function}{FormatDateTime}
  426. \Declaration
  427. Function FormatDateTime(FormatStr: string; DateTime: TDateTime):string;
  428. \Description
  429. \var{FormatDateTime} formats the date and time encoded in \var{DateTime}
  430. according to the formatting given in \var{FormatStr}. The complete list
  431. of formatting characters can be found in \sees{formatchars}.
  432. \Errors
  433. On error (such as an invalid character in the formatting string), and
  434. \var{EConvertError} exception is raised.
  435. \SeeAlso
  436. \seef{DateTimeToStr}, \seef{DateToStr}, \seef{TimeToStr},
  437. \seef{StrToDateTime}
  438. \end{function}
  439. \latex{\inputlisting{sysutex/ex14.pp}}
  440. \html{\input{sysutex/ex14.tex}}
  441. \begin{function}{IncMonth}
  442. \Declaration
  443. Function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer): TDateTime;
  444. \Description
  445. \var{IncMonth} increases the month number in \var{DateTime} with
  446. \var{NumberOfMonths}. It wraps the result as to get a month between 1 and
  447. 12, and updates the year accordingly. \var{NumberOfMonths} can be negative,
  448. and can be larger than 12 (in absolute value).
  449. \Errors
  450. None.
  451. \SeeAlso
  452. \seef{Date}, \seef{Time}, \seef{Now}
  453. \end{function}
  454. \latex{\inputlisting{sysutex/ex15.pp}}
  455. \html{\input{sysutex/ex15.tex}}
  456. \begin{function}{IsLeapYear}
  457. \Declaration
  458. Function IsLeapYear(Year: Word): boolean;
  459. \Description
  460. \var{IsLeapYear} returns \var{True} if \var{Year} is a leap year,
  461. \var{False} otherwise.
  462. \Errors
  463. None.
  464. \SeeAlso
  465. \seef{IncMonth}, \seef{Date}
  466. \end{function}
  467. \latex{\inputlisting{sysutex/ex16.pp}}
  468. \html{\input{sysutex/ex16.tex}}
  469. \begin{function}{MSecsToTimeStamp}
  470. \Declaration
  471. Function MSecsToTimeStamp(MSecs: Comp): TTimeStamp;
  472. \Description
  473. \var{MSecsTiTimeStamp} converts the given number of milliseconds to
  474. a \var{TTimeStamp} date/time notation.
  475. Use \var{TTimeStamp} variables if you need to keep very precise track of
  476. time.
  477. \Errors
  478. None.
  479. \SeeAlso
  480. \seef{TimeStampToMSecs}, \seef{DateTimeToTimeStamp},
  481. \end{function}
  482. \latex{\inputlisting{sysutex/ex17.pp}}
  483. \html{\input{sysutex/ex17.tex}}
  484. \begin{function}{Now}
  485. \Declaration
  486. Function Now: TDateTime;
  487. \Description
  488. \var{Now} returns the current date and time. It is equivalent to
  489. \var{Date+Time}.
  490. \Errors
  491. None.
  492. \SeeAlso
  493. \seef{Date}, \seef{Time}
  494. \end{function}
  495. \latex{\inputlisting{sysutex/ex18.pp}}
  496. \html{\input{sysutex/ex18.tex}}
  497. \begin{function}{StrToDate}
  498. \Declaration
  499. Function StrToDate(const S: string): TDateTime;
  500. \Description
  501. \var{StrToDate} converts the string \var{S} to a \var{TDateTime} date
  502. value. The Date must consist of 1 to three digits, separated by the
  503. \var{DateSeparator} character. If two numbers are given, they
  504. are supposed to form the day and month of the current year. If only
  505. one number is given, it is supposed to represent the day of the
  506. current month. (This is \em{not} supported in Delphi)
  507. The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the
  508. \var{ShortDateFormat} variable.
  509. \Errors
  510. On error (e.g. an invalid date or invalid character),
  511. an \var{EConvertError} exception is raised.
  512. \SeeAlso
  513. \seef{StrToTime}, \seef{DateToStr}n \seef{TimeToStr}.
  514. \end{function}
  515. \latex{\inputlisting{sysutex/ex19.pp}}
  516. \html{\input{sysutex/ex19.tex}}
  517. \begin{function}{StrToDateTime}
  518. \Declaration
  519. Function StrToDateTime(const S: string): TDateTime;
  520. \Description
  521. \var{StrToDateTime} converts the string \var{S} to a \var{TDateTime} date
  522. and time value. The Date must consist of 1 to three digits, separated by the
  523. \var{DateSeparator} character. If two numbers are given, they
  524. are supposed to form the day and month of the current year. If only
  525. one number is given, it is supposed to represent the day of the
  526. current month. (This is \em{not} supported in Delphi)
  527. The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the
  528. \var{ShortDateFormat} variable.
  529. \Errors
  530. On error (e.g. an invalid date or invalid character),
  531. an \var{EConvertError} exception is raised.
  532. \SeeAlso
  533. \seef{StrToDate}, \seef{StrToTime}, \seef{DateTimeToStr}
  534. \end{function}
  535. \latex{\inputlisting{sysutex/ex20.pp}}
  536. \html{\input{sysutex/ex20.tex}}
  537. \begin{function}{StrToTime}
  538. \Declaration
  539. Function StrToTime(const S: string): TDateTime;
  540. \Description
  541. \var{StrToTime} converts the string \var{S} to a \var{TDateTime} time
  542. value. The time must consist of 1 to 4 digits, separated by the
  543. \var{TimeSeparator} character. If two numbers are given, they
  544. are supposed to form the hour and minutes.
  545. \Errors
  546. On error (e.g. an invalid date or invalid character),
  547. an \var{EConvertError} exception is raised.
  548. \SeeAlso
  549. \seef{StrToDate}, \seef{StrToDateTime}, \seef{TimeToStr}
  550. \end{function}
  551. \latex{\inputlisting{sysutex/ex21.pp}}
  552. \html{\input{sysutex/ex21.tex}}
  553. \begin{function}{SystemTimeToDateTime}
  554. \Declaration
  555. Function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
  556. \Description
  557. \var{SystemTimeToDateTime} converts a \var{TSystemTime} record to a
  558. \var{TDateTime} style date/time indication.
  559. \Errors
  560. None.
  561. \SeeAlso
  562. \seep{DateTimeToSystemTime}
  563. \end{function}
  564. \latex{\inputlisting{sysutex/ex22.pp}}
  565. \html{\input{sysutex/ex22.tex}}
  566. \begin{function}{Time}
  567. \Declaration
  568. Function Time: TDateTime;
  569. \Description
  570. \var{Time} returns the current time in \var{TDateTime} format. The date
  571. part of the \var{TDateTimeValue} is set to zero.
  572. \Errors
  573. None.
  574. \SeeAlso
  575. \seef{Now}, \seef{Date}
  576. \end{function}
  577. \latex{\inputlisting{sysutex/ex23.pp}}
  578. \html{\input{sysutex/ex23.tex}}
  579. \begin{function}{TimeStampToDateTime}
  580. \Declaration
  581. Function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;
  582. \Description
  583. \var{TimeStampToDateTime} converts \var{TimeStamp} to a \var{TDateTime}
  584. format variable. It is the inverse operation of \seef{DateTimeToTimeStamp}.
  585. \Errors
  586. None.
  587. \SeeAlso
  588. \seef{DateTimeToTimeStamp}, \seef{TimeStampToMSecs}
  589. \end{function}
  590. \latex{\inputlisting{sysutex/ex24.pp}}
  591. \html{\input{sysutex/ex24.tex}}
  592. \begin{function}{TimeStampToMSecs}
  593. \Declaration
  594. Function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
  595. \Description
  596. \var{TimeStampToMSecs} converts {TimeStamp} to the number of seconds
  597. since \var{1/1/0001}.
  598. Use \var{TTimeStamp} variables if you need to keep very precise track of
  599. time.
  600. \Errors
  601. None.
  602. \SeeAlso
  603. \seef{MSecsToTimeStamp}, \seef{TimeStampToDateTime}
  604. \end{function}
  605. For an example, see \seef{MSecsToTimeStamp}.
  606. \begin{function}{TimeToStr}
  607. \Declaration
  608. Function TimeToStr(Time: TDateTime): string;
  609. \Description
  610. \var{TimeToStr} converts the time in \var{Time} to a string. It uses
  611. the \var{ShortTimeFormat} variable to see what formatting needs to be
  612. applied. It is therefor entirely equivalent to a
  613. \var{FormatDateTime('t',Time)} call.
  614. \Errors
  615. None.
  616. \SeeAlso
  617. \end{function}
  618. \latex{\inputlisting{sysutex/ex25.pp}}
  619. \html{\input{sysutex/ex25.tex}}
  620. \section{Disk functions}
  621. \begin{functionl}{AddDisk (Linux only)}{AddDisk}
  622. \Declaration
  623. Function AddDisk (Const PAth : String) : Longint;
  624. \Description
  625. On Linux both the \seef{Diskfree} and \seef{Disksize} functions need a
  626. file on the specified drive, since is required for the statfs system call.
  627. These filenames are set in drivestr[0..26], and the first 4 have been
  628. preset to :
  629. \begin{description}
  630. \item[Disk 0] \var{'.'} default drive - hence current directory is used.
  631. \item[Disk 1] \var{'/fd0/.'} floppy drive 1.
  632. \item[Disk 2] \var{'/fd1/.'} floppy drive 2.
  633. \item[Disk 3] \var{'/'} \file{C:} equivalent of DOS is the root partition.
  634. \end{description}
  635. Drives 4..26 can be set by your own applications with the \var{AddDisk} call.
  636. The \var{AddDisk} call adds \var{Path} to the names of drive files, and
  637. returns the number of the disk that corresponds to this drive. If you
  638. add more than 21 drives, the count is wrapped to 4.
  639. \Errors
  640. None.
  641. \SeeAlso
  642. \seef{DiskFree}, \seef{DiskSize}
  643. \end{functionl}
  644. \begin{function}{CreateDir}
  645. \Declaration
  646. Function CreateDir(Const NewDir : String) : Boolean;
  647. \Description
  648. \var{CreateDir} creates a new directory with name \var{NewDir}.
  649. If the directory doesn't contain an absolute path, then the directory is
  650. created below the current working directory.
  651. The function returns \var{True} if the directory was successfully
  652. created, \var{False} otherwise.
  653. \Errors
  654. In case of an error, the function returns \var{False}.
  655. \SeeAlso
  656. \seef{RemoveDir}
  657. \end{function}
  658. \latex{\inputlisting{sysutex/ex26.pp}}
  659. \html{\input{sysutex/ex26.tex}}
  660. \begin{function}{DiskFree}
  661. \Declaration
  662. Function DiskFree(Drive : Byte) : Longint;
  663. \Description
  664. \var{DiskFree} returns the free space (in bytes) on disk \var{Drive}.
  665. Drive is the number of the disk drive:
  666. \begin{description}
  667. \item[0] for the current drive.
  668. \item[1] for the first floppy drive.
  669. \item[2] for the second floppy drive.
  670. \item[3] for the first hard-disk parttion.
  671. \item[4-26] for all other drives and partitions.
  672. \end{description}
  673. {\em Remark} Under \linux, and Unix in general, the concept of disk is
  674. different than the \dos one, since the filesystem is seen as one big
  675. directory tree. For this reason, the \var{DiskFree} and \seef{DiskSize}
  676. functions must be mimicked using filenames that reside on the partitions.
  677. For more information, see \seef{AddDisk}
  678. \Errors
  679. On error, \var{-1} is returned.
  680. \SeeAlso
  681. \seef{DiskSize}, \seef{AddDisk}
  682. \end{function}
  683. \latex{\inputlisting{sysutex/ex27.pp}}
  684. \html{\input{sysutex/ex27.tex}}
  685. \begin{function}{DiskSize}
  686. \Declaration
  687. Function DiskSize(Drive : Byte) : Longint;
  688. \Description
  689. \var{DiskSize} returns the size (in bytes) of disk \var{Drive}.
  690. Drive is the number of the disk drive:
  691. \begin{description}
  692. \item[0] for the current drive.
  693. \item[1] for the first floppy drive.
  694. \item[2] for the second floppy drive.
  695. \item[3] for the first hard-disk parttion.
  696. \item[4-26] for all other drives and partitions.
  697. \end{description}
  698. {\em Remark} Under \linux, and Unix in general, the concept of disk is
  699. different than the \dos one, since the filesystem is seen as one big
  700. directory tree. For this reason, the \seef{DiskFree} and \var{DiskSize}
  701. functions must be mimicked using filenames that reside on the partitions.
  702. For more information, see \seef{AddDisk}
  703. \Errors
  704. On error, \var{-1} is returned.
  705. \SeeAlso
  706. \seef{DiskFree}, \seef{AddDisk}
  707. \end{function}
  708. For an example, see \seef{DiskFree}.
  709. \begin{function}{GetCurrentDir}
  710. \Declaration
  711. Function GetCurrentDir : String;
  712. \Description
  713. \var{GetCurrentDir} returns the current working directory.
  714. \Errors
  715. None.
  716. \SeeAlso
  717. \seef{SetCurrentDir}, \seef{DiskFree}, \seef{DiskSize}
  718. \end{function}
  719. \latex{\inputlisting{sysutex/ex28.pp}}
  720. \html{\input{sysutex/ex28.tex}}
  721. \begin{function}{RemoveDir}
  722. \Declaration
  723. Function RemoveDir(Const Dir : String) : Boolean;
  724. \Description
  725. \var{RemoveDir} removes directory \var{Dir} from the disk.
  726. If the directory is not absolue, it is appended to the current working
  727. directory.
  728. \Errors
  729. In case of error (e.g. the directory isn't empty) the function returns
  730. \var{False}. If successful, \var{True} is returned.
  731. \SeeAlso
  732. \end{function}
  733. For an example, see \seef{CreateDir}.
  734. \begin{function}{SetCurrentDir}
  735. \Declaration
  736. Function SetCurrentDir(Const NewDir : String) : Boolean;
  737. \Description
  738. \var{SetCurrentDir} sets the current working directory of your program
  739. to \var{NewDir}. It returns \var{True} if the function was successfull,
  740. \var{False} otherwise.
  741. \Errors
  742. In case of error, \var{False} is returned.
  743. \SeeAlso
  744. \seef{GetCurrentDir}
  745. \end{function}
  746. \latex{\inputlisting{sysutex/ex29.pp}}
  747. \html{\input{sysutex/ex29.tex}}
  748. \section{File handling functions}
  749. \begin{function}{ChangeFileExt}
  750. \Declaration
  751. Function ChangeFileExt(const FileName, Extension: string): string;
  752. \Description
  753. \var{ChangeFileExt} changes the file extension in \var{FileName} to
  754. \var{Extension}.
  755. The extension \var{Extension} includes the starting \var{.} (dot).
  756. The previous extension of \var{FileName} are all characters after the
  757. last \var{.}, the \var{.} character included.
  758. If \var{FileName} doesn't have an extension, \var{Extension} is just
  759. appended.
  760. \Errors
  761. None.
  762. \SeeAlso
  763. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExpandFileName}
  764. \end{function}
  765. \begin{function}{DeleteFile}
  766. \Declaration
  767. Function DeleteFile(Const FileName : String) : Boolean;
  768. \Description
  769. \var{DeleteFile} deletes file \var{FileName} from disk. The function
  770. returns \var{True} if the file was successfully removed, \var{False}
  771. otherwise.
  772. \Errors
  773. On error, \var{False} is returned.
  774. \SeeAlso
  775. \seef{CreateFile}, \seef{FileExists}
  776. \end{function}
  777. \latex{\inputlisting{sysutex/ex31.pp}}
  778. \html{\input{sysutex/ex31.tex}}
  779. \begin{procedure}{DoDirSeparators}
  780. \Declaration
  781. Procedure DoDirSeparators(Var FileName : String);
  782. \Description
  783. This function replaces all directory separators \var{'\' and '/'}
  784. to the directory separator character for the current system.
  785. \Errors
  786. None.
  787. \SeeAlso
  788. \seef{ExtractFileName}, \seef{ExtractFilePath}
  789. \end{procedure}
  790. \latex{\inputlisting{sysutex/ex32.pp}}
  791. \html{\input{sysutex/ex32.tex}}
  792. \begin{function}{ExpandFileName}
  793. \Declaration
  794. Function ExpandFileName(Const FileName : string): String;
  795. \Description
  796. \var{ExpandFileName} expands the filename to an absolute filename.
  797. It changes all directory separator characters to the one appropriate for the
  798. system first.
  799. \Errors
  800. None.
  801. \SeeAlso
  802. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  803. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  804. \end{function}
  805. \latex{\inputlisting{sysutex/ex33.pp}}
  806. \html{\input{sysutex/ex33.tex}}
  807. \begin{function}{ExpandUNCFileName}
  808. \Declaration
  809. Function ExpandUNCFileName(Const FileName : string): String;
  810. \Description
  811. \var{ExpandUNCFileName} runs \seef{ExpandFileName} on \var{FileName}
  812. and then attempts to replace the driveletter by the name of a shared disk.
  813. \Errors
  814. \SeeAlso
  815. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  816. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  817. \end{function}
  818. \begin{function}{ExtractFileDir}
  819. \Declaration
  820. Function ExtractFileDir(Const FileName : string): string;
  821. \Description
  822. \var{ExtractFileDir} returns only the directory part of \var{FileName},
  823. not including a driveletter. The directory name has NO ending directory
  824. separator, in difference with \seef{ExtractFilePath}.
  825. \Errors
  826. None.
  827. \SeeAlso
  828. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  829. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  830. \end{function}
  831. \latex{\inputlisting{sysutex/ex34.pp}}
  832. \html{\input{sysutex/ex34.tex}}
  833. \begin{function}{ExtractFileDrive}
  834. \Declaration
  835. Function ExtractFileDrive(const FileName: string): string;
  836. \Description
  837. \var{Extract}
  838. \Errors
  839. \SeeAlso
  840. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  841. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  842. \end{function}
  843. For an example, see \seef{ExtractFileDir}.
  844. \begin{function}{ExtractFileExt}
  845. \Declaration
  846. Function ExtractFileExt(const FileName: string): string;
  847. \Description
  848. \var{ExtractFileExt} returns the extension (including the
  849. \var{.}(dot) character) of \var{FileName}.
  850. \Errors
  851. None.
  852. \SeeAlso
  853. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  854. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  855. \end{function}
  856. For an example, see \seef{ExtractFileDir}.
  857. \begin{function}{ExtractFileName}
  858. \Declaration
  859. Function ExtractFileName(const FileName: string): string;
  860. \Description
  861. \var{ExtractFileName} returns the filename part from \var{FileName}.
  862. The filename consists of all characters after the last directory separator
  863. character ('/' or '\') or drive letter.
  864. The full filename can always be reconstucted by concatenating the result
  865. of \seef{ExtractFilePath} and \var{ExtractFileName}.
  866. \Errors
  867. None.
  868. \SeeAlso
  869. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  870. \seef{ExtractFileDrive}, \seef{ExtractFileExt},\seef{ExtractRelativePath}
  871. \end{function}
  872. For an example, see \seef{ExtractFileDir}.
  873. \begin{function}{ExtractFilePath}
  874. \Declaration
  875. Function ExtractFilePath(const FileName: string): string;
  876. \Description
  877. \var{ExtractFilePath} returns the path part (including driveletter) from
  878. \var{FileName}. The path consists of all characters before the last
  879. directory separator character ('/' or '\'), including the directory
  880. separator itself.
  881. In case there is only a drive letter, that will be returned.
  882. The full filename can always be reconstucted by concatenating the result
  883. of \var{ExtractFilePath} and \seef{ExtractFileName}.
  884. \Errors
  885. None.
  886. \SeeAlso
  887. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  888. \seef{ExtractFileDrive}, \seef{ExtractFileExt}, \seef{ExtractRelativePath}
  889. \end{function}
  890. For an example, see \seef{ExtractFileDir}.
  891. \begin{function}{ExtractRelativePath}
  892. \Declaration
  893. Function ExtractRelativePath(Const BaseName,DestNAme : String): String;
  894. \Description
  895. \var{ExtractRelativePath} constructs a relative path to go from
  896. \var{BaseName} to \var{DestName}. If \var{DestName} is on another drive
  897. (Not on Linux) then the whole \var{Destname} is returned.
  898. {\em Note:} This function does not exist in the Delphi unit.
  899. \Errors
  900. None.
  901. \SeeAlso
  902. \seef{ExtractFileName}, \seef{ExtractFilePath}, \seef{ExtractFileDir},
  903. \seef{ExtractFileDrive}, \seef{ExtractFileExt},
  904. \end{function}
  905. \latex{\inputlisting{sysutex/ex35.pp}}
  906. \html{\input{sysutex/ex35.tex}}
  907. \begin{function}{FileAge}
  908. \Declaration
  909. Function FileAge(Const FileName : String): Longint;
  910. \Description
  911. \var{FileAge} returns the last modification time of file \var{FileName}.
  912. The FileDate format can be transformed to \var{TDateTime} format with the
  913. \seef{FileDateToDateTime} function.
  914. \Errors
  915. In case of errors, \var{-1} is returned.
  916. \SeeAlso
  917. \seef{FileDateToDateTime}, \seef{FileExists}, \seef{FileGetAttr}
  918. \end{function}
  919. \latex{\inputlisting{sysutex/ex36.pp}}
  920. \html{\input{sysutex/ex36.tex}}
  921. \begin{procedure}{FileClose}
  922. \Declaration
  923. Procedure FileClose(Handle : Longint);
  924. \Description
  925. \var{FileClose} closes the file handle \var{Handle}. After this call,
  926. attempting to read or write from the handle will result in an error.
  927. \Errors
  928. None.
  929. \SeeAlso
  930. \seef{FileCreate}, \seef{FileWrite}, \seef{FileOpen}, \seef{FileRead},
  931. \seef{FileTruncate}, \seef{FileSeek}
  932. \end{procedure}
  933. \begin{function}{FileCreate}
  934. \Declaration
  935. Function FileCreate(Const FileName : String) : Longint;
  936. \Description
  937. \var{FileCreate} creates a new file with name \var{FileName} on the disk and
  938. returns a file handle which can be used to read or write from the file with
  939. the \seef{FileRead} and \seef{FileWrite} functions.
  940. If a file with name \var{FileName} already existed on the disk, it is
  941. overwritten.
  942. \Errors
  943. If an error occurs (e.g. disk full or non-existent path), the function
  944. returns \var{-1}.
  945. \SeeAlso
  946. \seef{FileClose}, \seef{FileWrite}, \seef{FileOpen}, \seef{FileRead},
  947. \seef{FileTruncate}, \seef{FileSeek}
  948. \end{function}
  949. \begin{function}{FileExists}
  950. \Declaration
  951. Function FileExists(Const FileName : String) : Boolean;
  952. \Description
  953. \var{FileExists} returns \var{True} if a file with name \var{FileName}
  954. exists on the disk, \var{False} otherwise.
  955. \Errors
  956. None.
  957. \SeeAlso
  958. \seef{FileAge}, \seef{FileGetAttr}, \seef{FileSetAttr}
  959. \end{function}
  960. \begin{function}{FileGetAttr}
  961. \Declaration
  962. Function FileGetAttr(Const FileName : String) : Longint;
  963. \Description
  964. \var{FileGetAttr} returns the attribute settings of file
  965. \var{FileName}. The attribute is a \var{OR}-ed combination
  966. of the following constants:
  967. \begin{description}
  968. \item[faReadOnly] The file is read-only.
  969. \item[faHidden] The file is hidden. (On \linux, this means that the filename
  970. starts with a dot)
  971. \item[faSysFile] The file is a system file (On \linux, this means that the
  972. file is a character, block or FIFO file).
  973. \item[faVolumeId] Volume Label. Not possible under \linux.
  974. \item[faDirectory] File is a directory.
  975. \item[faArchive] file is an archive. Not possible on \linux.
  976. \end{description}
  977. \Errors
  978. In case of error, -1 is returned.
  979. \SeeAlso
  980. \seef{FileSetAttr}, \seef{FileAge}, \seef{FileGetDate}.
  981. \end{function}
  982. \begin{function}{FileGetDate}
  983. \Declaration
  984. Function FileGetDate(Handle : Longint) : Longint;
  985. \Description
  986. \Errors
  987. \SeeAlso
  988. \end{function}
  989. \begin{function}{FileOpen}
  990. \Declaration
  991. Function FileOpen(Const FileName : string; Mode : Integer) : Longint;
  992. \Description
  993. \Errors
  994. \SeeAlso
  995. \seef{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileRead},
  996. \seef{FileTruncate}, \seef{FileSeek}
  997. \end{function}
  998. \begin{function}{FileRead}
  999. \Declaration
  1000. Function FileRead(Handle : Longint; Var Buffer; Count : longint) : Longint;
  1001. \Description
  1002. \Errors
  1003. \SeeAlso
  1004. \seef{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen},
  1005. \seef{FileTruncate}, \seef{FileSeek}
  1006. \end{function}
  1007. \begin{function}{FileSearch}
  1008. \Declaration
  1009. Function FileSearch(Const Name, DirList : String) : String;
  1010. \Description
  1011. \Errors
  1012. \SeeAlso
  1013. \end{function}
  1014. \begin{function}{FileSeek}
  1015. \Declaration
  1016. Function FileSeek(Handle,Offset,Origin : Longint) : Longint;
  1017. \Description
  1018. \Errors
  1019. \SeeAlso
  1020. \seef{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen}
  1021. \seef{FileRead}, \seef{FileTruncate}
  1022. \end{function}
  1023. \begin{function}{FileSetAttr}
  1024. \Declaration
  1025. Function FileSetAttr(Const Filename : String; Attr: longint) : Longint;
  1026. \Description
  1027. \Errors
  1028. \SeeAlso
  1029. \end{function}
  1030. \begin{function}{FileSetDate}
  1031. \Declaration
  1032. Function FileSetDate(Handle,Age : Longint) : Longint;
  1033. \Description
  1034. \Errors
  1035. \SeeAlso
  1036. \end{function}
  1037. \begin{function}{FileTruncate}
  1038. \Declaration
  1039. Function FileTruncate(Handle,Size: Longint) : boolean;
  1040. \Description
  1041. \Errors
  1042. \SeeAlso
  1043. \seef{FileClose}, \seef{FileWrite}, \seef{FileCreate}, \seef{FileOpen}
  1044. \seef{FileRead}, \seef{FileSeek}
  1045. \end{function}
  1046. \begin{function}{FileWrite}
  1047. \Declaration
  1048. Function FileWrite(Handle : Longint; Var Buffer; Count : Longint) : Longint;
  1049. \Description
  1050. \Errors
  1051. \SeeAlso
  1052. \seef{FileClose}, \seef{FileCreate}, \seef{FileOpen}
  1053. \seef{FileRead}, \seef{FileTruncate}, \seef{FileSeek}
  1054. \end{function}
  1055. \begin{procedure}{FindClose}
  1056. \Declaration
  1057. Procedure FindClose(Var F : TSearchrec);
  1058. \Description
  1059. \Errors
  1060. \SeeAlso
  1061. \end{procedure}
  1062. \begin{function}{FindFirst}
  1063. \Declaration
  1064. Function FindFirst(Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
  1065. \Description
  1066. \Errors
  1067. \SeeAlso
  1068. \end{function}
  1069. \begin{function}{FindNext}
  1070. \Declaration
  1071. Function FindNext(Var Rslt : TSearchRec) : Longint;
  1072. \Description
  1073. \Errors
  1074. \SeeAlso
  1075. \end{function}
  1076. \begin{function}{GetDirs}
  1077. \Declaration
  1078. Function GetDirs(Var DirName : String; Var Dirs : Array of pchar) : Longint;
  1079. \Description
  1080. \Errors
  1081. \SeeAlso
  1082. \end{function}
  1083. \begin{function}{RenameFile}
  1084. \Declaration
  1085. Function RenameFile(Const OldName, NewName : String) : Boolean;
  1086. \Description
  1087. \Errors
  1088. \SeeAlso
  1089. \end{function}
  1090. \begin{function}{SetDirSeparators}
  1091. \Declaration
  1092. Function SetDirSeparators(Const FileName : String) : String;
  1093. \Description
  1094. \Errors
  1095. \SeeAlso
  1096. \end{function}
  1097. \section{PChar functions}
  1098. \begin{function}{StrAlloc}
  1099. \Declaration
  1100. Function StrAlloc(Size: cardinal): PChar;
  1101. \Description
  1102. \Errors
  1103. \SeeAlso
  1104. \end{function}
  1105. \begin{function}{StrBufSize}
  1106. \Declaration
  1107. Function StrBufSize(var Str: PChar): cardinal;
  1108. \Description
  1109. \Errors
  1110. \SeeAlso
  1111. \end{function}
  1112. \begin{procedure}{StrDispose}
  1113. \Declaration
  1114. Procedure StrDispose(var Str: PChar);
  1115. \Description
  1116. \Errors
  1117. \SeeAlso
  1118. \end{procedure}
  1119. \begin{function}{StrPCopy}
  1120. \Declaration
  1121. Function StrPCopy(Dest: PChar; Source: string): PChar;
  1122. \Description
  1123. \Errors
  1124. \SeeAlso
  1125. \end{function}
  1126. \begin{function}{StrPLCopy}
  1127. \Declaration
  1128. Function StrPLCopy(Dest: PChar; Source: string; MaxLen: cardinal): PChar;
  1129. \Description
  1130. \Errors
  1131. \SeeAlso
  1132. \end{function}
  1133. \begin{function}{StrPas}
  1134. \Declaration
  1135. Function StrPas(Str: PChar): string;
  1136. \Description
  1137. \Errors
  1138. \SeeAlso
  1139. \end{function}
  1140. \begin{function}{StrCat}
  1141. \Declaration
  1142. Function StrCat(dest,source : pchar) : pchar;
  1143. \Description
  1144. \Errors
  1145. \SeeAlso
  1146. \end{function}
  1147. \begin{function}{StrComp}
  1148. \Declaration
  1149. Function StrComp(str1,str2 : pchar) : longint;
  1150. \Description
  1151. \Errors
  1152. \SeeAlso
  1153. \end{function}
  1154. \begin{function}{StrCopy}
  1155. \Declaration
  1156. Function StrCopy(dest,source : pchar) : pchar;
  1157. \Description
  1158. \Errors
  1159. \SeeAlso
  1160. \end{function}
  1161. \begin{function}{StrECopy}
  1162. \Declaration
  1163. Function StrECopy(dest,source : pchar) : pchar;
  1164. \Description
  1165. \Errors
  1166. \SeeAlso
  1167. \end{function}
  1168. \begin{function}{StrEnd}
  1169. \Declaration
  1170. Function StrEnd(p : pchar) : pchar;
  1171. \Description
  1172. \Errors
  1173. \SeeAlso
  1174. \end{function}
  1175. \begin{function}{StrIComp}
  1176. \Declaration
  1177. Function StrIComp(str1,str2 : pchar) : longint;
  1178. \Description
  1179. \Errors
  1180. \SeeAlso
  1181. \end{function}
  1182. \begin{function}{StrLCat}
  1183. \Declaration
  1184. Function StrLCat(dest,source : pchar;l : longint) : pchar;
  1185. \Description
  1186. \Errors
  1187. \SeeAlso
  1188. \end{function}
  1189. \begin{function}{StrLComp}
  1190. \Declaration
  1191. Function StrLComp(str1,str2 : pchar;l : longint) : longint;
  1192. \Description
  1193. \Errors
  1194. \SeeAlso
  1195. \end{function}
  1196. \begin{function}{StrLCopy}
  1197. \Declaration
  1198. Function StrLCopy(dest,source : pchar;maxlen : longint) : pchar;
  1199. \Description
  1200. \Errors
  1201. \SeeAlso
  1202. \end{function}
  1203. \begin{function}{StrLen}
  1204. \Declaration
  1205. Function StrLen(p : pchar) : longint;
  1206. \Description
  1207. \Errors
  1208. \SeeAlso
  1209. \end{function}
  1210. \begin{function}{StrLIComp}
  1211. \Declaration
  1212. Function StrLIComp(str1,str2 : pchar;l : longint) : longint;
  1213. \Description
  1214. \Errors
  1215. \SeeAlso
  1216. \end{function}
  1217. \begin{function}{StrLower}
  1218. \Declaration
  1219. Function strlower(p : pchar) : pchar;
  1220. \Description
  1221. \Errors
  1222. \SeeAlso
  1223. \end{function}
  1224. \begin{function}{StrMove}
  1225. \Declaration
  1226. Function StrMove(dest,source : pchar;l : longint) : pchar;
  1227. \Description
  1228. \Errors
  1229. \SeeAlso
  1230. \end{function}
  1231. \begin{function}{StrNew}
  1232. \Declaration
  1233. Function StrNew(p : pchar) : pchar;
  1234. \Description
  1235. \Errors
  1236. \SeeAlso
  1237. \end{function}
  1238. \begin{function}{StrPos}
  1239. \Declaration
  1240. Function StrPos(str1,str2 : pchar) : pchar;
  1241. \Description
  1242. \Errors
  1243. \SeeAlso
  1244. \end{function}
  1245. \begin{function}{StrRScan}
  1246. \Declaration
  1247. Function StrRScan(p : pchar;c : char) : pchar;
  1248. \Description
  1249. \Errors
  1250. \SeeAlso
  1251. \end{function}
  1252. \begin{function}{StrScan}
  1253. \Declaration
  1254. Function StrScan(p : pchar;c : char) : pchar;
  1255. \Description
  1256. \Errors
  1257. \SeeAlso
  1258. \end{function}
  1259. \begin{function}{StrUpper}
  1260. \Declaration
  1261. Function StrUpper(p : pchar) : pchar;
  1262. \Description
  1263. \Errors
  1264. \SeeAlso
  1265. \end{function}
  1266. \section{String functions}
  1267. \begin{function}{AdjustLineBreaks}
  1268. \Declaration
  1269. Function AdjustLineBreaks(const S: string): string;
  1270. \Description
  1271. \Errors
  1272. \SeeAlso
  1273. \end{function}
  1274. \begin{function}{AnsiCompareStr}
  1275. \Declaration
  1276. Function AnsiCompareStr(const S1, S2: string): integer;
  1277. \Description
  1278. \Errors
  1279. \SeeAlso
  1280. \end{function}
  1281. \begin{function}{AnsiCompareText}
  1282. \Declaration
  1283. Function AnsiCompareText(const S1, S2: string): integer;
  1284. \Description
  1285. \Errors
  1286. \SeeAlso
  1287. \end{function}
  1288. \begin{function}{AnsiExtractQuotedStr}
  1289. \Declaration
  1290. Function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
  1291. \Description
  1292. \Errors
  1293. \SeeAlso
  1294. \end{function}
  1295. \begin{function}{AnsiLastChar}
  1296. \Declaration
  1297. Function AnsiLastChar(const S: string): PChar;
  1298. \Description
  1299. \Errors
  1300. \SeeAlso
  1301. \end{function}
  1302. \begin{function}{AnsiLowerCase}
  1303. \Declaration
  1304. Function AnsiLowerCase(const s: string): string;
  1305. \Description
  1306. \Errors
  1307. \SeeAlso
  1308. \end{function}
  1309. \begin{function}{AnsiQuotedStr}
  1310. \Declaration
  1311. Function AnsiQuotedStr(const S: string; Quote: char): string;
  1312. \Description
  1313. \Errors
  1314. \SeeAlso
  1315. \end{function}
  1316. \begin{function}{AnsiStrComp}
  1317. \Declaration
  1318. Function AnsiStrComp(S1, S2: PChar): integer;
  1319. \Description
  1320. \Errors
  1321. \SeeAlso
  1322. \end{function}
  1323. \begin{function}{AnsiStrIComp}
  1324. \Declaration
  1325. Function AnsiStrIComp(S1, S2: PChar): integer;
  1326. \Description
  1327. \Errors
  1328. \SeeAlso
  1329. \end{function}
  1330. \begin{function}{AnsiStrLComp}
  1331. \Declaration
  1332. Function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1333. \Description
  1334. \Errors
  1335. \SeeAlso
  1336. \end{function}
  1337. \begin{function}{AnsiStrLIComp}
  1338. \Declaration
  1339. Function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1340. \Description
  1341. \Errors
  1342. \SeeAlso
  1343. \end{function}
  1344. \begin{function}{AnsiStrLast}
  1345. \Declaration
  1346. Function AnsiStrLast(Str: PChar): PChar;
  1347. \Description
  1348. \Errors
  1349. \SeeAlso
  1350. \end{function}
  1351. \begin{function}{CharAnsiStrLower}
  1352. \Declaration
  1353. Function AnsiStrLower(Str: PChar): PChar;
  1354. \Description
  1355. \Errors
  1356. \SeeAlso
  1357. \end{function}
  1358. \begin{function}{AnsiStrUpper}
  1359. \Declaration
  1360. Function AnsiStrUpper(Str: PChar): PChar;
  1361. \Description
  1362. \Errors
  1363. \SeeAlso
  1364. \end{function}
  1365. \begin{function}{AnsiUpperCase}
  1366. \Declaration
  1367. Function AnsiUpperCase(const s: string): string;
  1368. \Description
  1369. \Errors
  1370. \SeeAlso
  1371. \end{function}
  1372. \begin{procedure}{AppendStr}
  1373. \Declaration
  1374. Procedure AppendStr(var Dest: PString; const S: string);
  1375. \Description
  1376. \Errors
  1377. \SeeAlso
  1378. \end{procedure}
  1379. \begin{procedure}{AssignStr}
  1380. \Declaration
  1381. Procedure AssignStr(var P: PString; const S: string);
  1382. \Description
  1383. \Errors
  1384. \SeeAlso
  1385. \end{procedure}
  1386. \begin{function}{BCDToInt}
  1387. \Declaration
  1388. Function BCDToInt(Value: integer): integer;
  1389. \Description
  1390. \Errors
  1391. \SeeAlso
  1392. \end{function}
  1393. \begin{function}{CompareMem}
  1394. \Declaration
  1395. Function CompareMem(P1, P2: Pointer; Length: cardinal): integer;
  1396. \Description
  1397. \Errors
  1398. \SeeAlso
  1399. \end{function}
  1400. \begin{function}{CompareStr}
  1401. \Declaration
  1402. Function CompareStr(const S1, S2: string): Integer;
  1403. \Description
  1404. \Errors
  1405. \SeeAlso
  1406. \end{function}
  1407. \begin{function}{CompareText}
  1408. \Declaration
  1409. Function CompareText(const S1, S2: string): integer;
  1410. \Description
  1411. \Errors
  1412. \SeeAlso
  1413. \end{function}
  1414. \begin{procedure}{DisposeStr}
  1415. \Declaration
  1416. Procedure DisposeStr(S: PString);
  1417. \Description
  1418. \Errors
  1419. \SeeAlso
  1420. \end{procedure}
  1421. \begin{function}{FloatToStr}
  1422. \Declaration
  1423. Function FloatToStr(Value: Extended): String;
  1424. \Description
  1425. \Errors
  1426. \SeeAlso
  1427. \end{function}
  1428. \begin{function}{FloatToStrF}
  1429. \Declaration
  1430. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  1431. \Description
  1432. \Errors
  1433. \SeeAlso
  1434. \end{function}
  1435. \begin{procedure}{FmtStr}
  1436. \Declaration
  1437. Procedure (Var Res: String; Const Fmt : String; Const args: Array of const);
  1438. \Description
  1439. \Errors
  1440. \SeeAlso
  1441. \end{procedure}
  1442. \begin{function}{Format}
  1443. \Declaration
  1444. Function Format(Const Fmt : String; const Args : Array of const) : String;
  1445. \Description
  1446. \Errors
  1447. \SeeAlso
  1448. \end{function}
  1449. \begin{function}{FormatBuf}
  1450. \Declaration
  1451. Function FormatBuf(Var Buffer; BufLen : Cardinal; Const Fmt; fmtLen : Cardinal; Const Args : Array of const) : Cardinal;
  1452. \Description
  1453. \Errors
  1454. \SeeAlso
  1455. \end{function}
  1456. \begin{function}{IntToHex}
  1457. \Declaration
  1458. Function IntToHex(Value: integer; Digits: integer): string;
  1459. \Description
  1460. \Errors
  1461. \SeeAlso
  1462. \end{function}
  1463. \begin{function}{IntToStr}
  1464. \Declaration
  1465. Function IntToStr(Value: integer): string;
  1466. \Description
  1467. \Errors
  1468. \SeeAlso
  1469. \end{function}
  1470. \begin{function}{IsValidIdent}
  1471. \Declaration
  1472. Function IsValidIdent(const Ident: string): boolean;
  1473. \Description
  1474. \Errors
  1475. \SeeAlso
  1476. \end{function}
  1477. \begin{function}{LeftStr}
  1478. \Declaration
  1479. Function LeftStr(const S: string; Count: integer): string;
  1480. \Description
  1481. \Errors
  1482. \SeeAlso
  1483. \end{function}
  1484. \begin{function}{LoadStr}
  1485. \Declaration
  1486. Function LoadStr(Ident: integer): string;
  1487. \Description
  1488. \Errors
  1489. \SeeAlso
  1490. \end{function}
  1491. \begin{function}{LowerCase}
  1492. \Declaration
  1493. Function LowerCase(const s: string): string;
  1494. \Description
  1495. \Errors
  1496. \SeeAlso
  1497. \end{function}
  1498. \begin{function}{NewStr}
  1499. \Declaration
  1500. Function NewStr(const S: string): PString;
  1501. \Description
  1502. \Errors
  1503. \SeeAlso
  1504. \end{function}
  1505. \begin{function}{QuotedStr}
  1506. \Declaration
  1507. Function QuotedStr(const S: string): string;
  1508. \Description
  1509. \Errors
  1510. \SeeAlso
  1511. \end{function}
  1512. \begin{function}{RightStr}
  1513. \Declaration
  1514. Function RightStr(const S: string; Count: integer): string;
  1515. \Description
  1516. \Errors
  1517. \SeeAlso
  1518. \end{function}
  1519. \begin{function}{StrFmt}
  1520. \Declaration
  1521. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  1522. \Description
  1523. \Errors
  1524. \SeeAlso
  1525. \end{function}
  1526. \begin{function}{StrLFmt}
  1527. \Declaration
  1528. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  1529. \Description
  1530. \Errors
  1531. \SeeAlso
  1532. \end{function}
  1533. \begin{function}{StrToInt}
  1534. \Declaration
  1535. Function StrToInt(const s: string): integer;
  1536. \Description
  1537. \Errors
  1538. \SeeAlso
  1539. \end{function}
  1540. \begin{function}{StrToIntDef}
  1541. \Declaration
  1542. Function StrToIntDef(const S: string; Default: integer): integer;
  1543. \Description
  1544. \Errors
  1545. \SeeAlso
  1546. \end{function}
  1547. \begin{function}{Trim}
  1548. \Declaration
  1549. Function Trim(const S: string): string;
  1550. \Description
  1551. \Errors
  1552. \SeeAlso
  1553. \end{function}
  1554. \begin{function}{TrimLeft}
  1555. \Declaration
  1556. Function TrimLeft(const S: string): string;
  1557. \Description
  1558. \Errors
  1559. \SeeAlso
  1560. \end{function}
  1561. \begin{function}{TrimRight}
  1562. \Declaration
  1563. Function TrimRight(const S: string): string;
  1564. \Description
  1565. \Errors
  1566. \SeeAlso
  1567. \end{function}
  1568. \begin{function}{UpperCase}
  1569. \Declaration
  1570. Function UpperCase(const s: string): string;
  1571. \Description
  1572. \Errors
  1573. \SeeAlso
  1574. \end{function}