sysutils.tex 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954
  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 \seety{TDateTime}.
  238. \Errors
  239. None.
  240. \SeeAlso
  241. \seef{Time},\seef{Now}, \seety{TDateTime}.
  242. \end{function}
  243. \latex{\inputlisting{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{\inputlisting{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}, \seety{TDateTime}.
  272. \end{function}
  273. \latex{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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{\inputlisting{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. \begin{functionl}{StrPLCopy}{StrPLCopySys}
  1331. \Declaration
  1332. Function StrPLCopy(Dest: PChar; Source: string; MaxLen: cardinal): PChar;
  1333. \Description
  1334. \var{StrPLCopy} Converts maximally \var{MaxLen} characters of the
  1335. Ansistring in \var{Source} to a Null-terminated string, and copies
  1336. it to \var{Dest}. \var{Dest} needs enough room to contain
  1337. the characters.
  1338. \Errors
  1339. No checking is performed to see whether \var{Dest} points to enough memory
  1340. to contain L characters of \var{Source}.
  1341. \Errors
  1342. \SeeAlso
  1343. \seefl{StrPCopy}{StrPCopySys}.
  1344. \end{functionl}
  1345. \begin{functionl}{StrPas}{StrPasSys}
  1346. \Declaration
  1347. Function StrPas(Str: PChar): string;
  1348. \Description
  1349. Converts a null terminated string in \var{Str} to an Ansitring, and returns
  1350. this string. This string is NOT truncated at 255 characters as is the
  1351. \Errors
  1352. None.
  1353. \SeeAlso
  1354. \seef{StrPas}.
  1355. \end{functionl}
  1356. \section{String handling functions}
  1357. \begin{function}{AdjustLineBreaks}
  1358. \Declaration
  1359. Function AdjustLineBreaks(const S: string): string;
  1360. \Description
  1361. \Errors
  1362. \SeeAlso
  1363. \end{function}
  1364. \begin{function}{AnsiCompareStr}
  1365. \Declaration
  1366. Function AnsiCompareStr(const S1, S2: string): integer;
  1367. \Description
  1368. \Errors
  1369. \SeeAlso
  1370. \end{function}
  1371. \begin{function}{AnsiCompareText}
  1372. \Declaration
  1373. Function AnsiCompareText(const S1, S2: string): integer;
  1374. \Description
  1375. \Errors
  1376. \SeeAlso
  1377. \end{function}
  1378. \begin{function}{AnsiExtractQuotedStr}
  1379. \Declaration
  1380. Function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
  1381. \Description
  1382. \Errors
  1383. \SeeAlso
  1384. \end{function}
  1385. \begin{function}{AnsiLastChar}
  1386. \Declaration
  1387. Function AnsiLastChar(const S: string): PChar;
  1388. \Description
  1389. \Errors
  1390. \SeeAlso
  1391. \end{function}
  1392. \begin{function}{AnsiLowerCase}
  1393. \Declaration
  1394. Function AnsiLowerCase(const s: string): string;
  1395. \Description
  1396. \Errors
  1397. \SeeAlso
  1398. \end{function}
  1399. \begin{function}{AnsiQuotedStr}
  1400. \Declaration
  1401. Function AnsiQuotedStr(const S: string; Quote: char): string;
  1402. \Description
  1403. \Errors
  1404. \SeeAlso
  1405. \end{function}
  1406. \begin{function}{AnsiStrComp}
  1407. \Declaration
  1408. Function AnsiStrComp(S1, S2: PChar): integer;
  1409. \Description
  1410. \Errors
  1411. \SeeAlso
  1412. \end{function}
  1413. \begin{function}{AnsiStrIComp}
  1414. \Declaration
  1415. Function AnsiStrIComp(S1, S2: PChar): integer;
  1416. \Description
  1417. \Errors
  1418. \SeeAlso
  1419. \end{function}
  1420. \begin{function}{AnsiStrLComp}
  1421. \Declaration
  1422. Function AnsiStrLComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1423. \Description
  1424. \Errors
  1425. \SeeAlso
  1426. \end{function}
  1427. \begin{function}{AnsiStrLIComp}
  1428. \Declaration
  1429. Function AnsiStrLIComp(S1, S2: PChar; MaxLen: cardinal): integer;
  1430. \Description
  1431. \Errors
  1432. \SeeAlso
  1433. \end{function}
  1434. \begin{function}{AnsiStrLast}
  1435. \Declaration
  1436. Function AnsiStrLast(Str: PChar): PChar;
  1437. \Description
  1438. \Errors
  1439. \SeeAlso
  1440. \end{function}
  1441. \begin{function}{CharAnsiStrLower}
  1442. \Declaration
  1443. Function AnsiStrLower(Str: PChar): PChar;
  1444. \Description
  1445. \Errors
  1446. \SeeAlso
  1447. \end{function}
  1448. \begin{function}{AnsiStrUpper}
  1449. \Declaration
  1450. Function AnsiStrUpper(Str: PChar): PChar;
  1451. \Description
  1452. \Errors
  1453. \SeeAlso
  1454. \end{function}
  1455. \begin{function}{AnsiUpperCase}
  1456. \Declaration
  1457. Function AnsiUpperCase(const s: string): string;
  1458. \Description
  1459. \Errors
  1460. \SeeAlso
  1461. \end{function}
  1462. \begin{procedure}{AppendStr}
  1463. \Declaration
  1464. Procedure AppendStr(var Dest: PString; const S: string);
  1465. \Description
  1466. \Errors
  1467. \SeeAlso
  1468. \end{procedure}
  1469. \begin{procedure}{AssignStr}
  1470. \Declaration
  1471. Procedure AssignStr(var P: PString; const S: string);
  1472. \Description
  1473. \Errors
  1474. \SeeAlso
  1475. \end{procedure}
  1476. \begin{function}{BCDToInt}
  1477. \Declaration
  1478. Function BCDToInt(Value: integer): integer;
  1479. \Description
  1480. \Errors
  1481. \SeeAlso
  1482. \end{function}
  1483. \begin{function}{CompareMem}
  1484. \Declaration
  1485. Function CompareMem(P1, P2: Pointer; Length: cardinal): integer;
  1486. \Description
  1487. \Errors
  1488. \SeeAlso
  1489. \end{function}
  1490. \begin{function}{CompareStr}
  1491. \Declaration
  1492. Function CompareStr(const S1, S2: string): Integer;
  1493. \Description
  1494. \Errors
  1495. \SeeAlso
  1496. \end{function}
  1497. \begin{function}{CompareText}
  1498. \Declaration
  1499. Function CompareText(const S1, S2: string): integer;
  1500. \Description
  1501. \Errors
  1502. \SeeAlso
  1503. \end{function}
  1504. \begin{procedurel}{DisposeStr}{DisposeStrSys}
  1505. \Declaration
  1506. Procedure DisposeStr(S: PString);
  1507. \Description
  1508. \Errors
  1509. \SeeAlso
  1510. \end{procedurel}
  1511. \begin{function}{FloatToStr}
  1512. \Declaration
  1513. Function FloatToStr(Value: Extended): String;
  1514. \Description
  1515. \Errors
  1516. \SeeAlso
  1517. \end{function}
  1518. \begin{function}{FloatToStrF}
  1519. \Declaration
  1520. Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
  1521. \Description
  1522. \Errors
  1523. \SeeAlso
  1524. \end{function}
  1525. \begin{procedure}{FmtStr}
  1526. \Declaration
  1527. Procedure (Var Res: String; Const Fmt : String; Const args: Array of const);
  1528. \Description
  1529. \Errors
  1530. \SeeAlso
  1531. \end{procedure}
  1532. \begin{function}{Format}
  1533. \Declaration
  1534. Function Format(Const Fmt : String; const Args : Array of const) : String;
  1535. \Description
  1536. \Errors
  1537. \SeeAlso
  1538. \end{function}
  1539. \begin{function}{FormatBuf}
  1540. \Declaration
  1541. Function FormatBuf(Var Buffer; BufLen : Cardinal; Const Fmt; fmtLen : Cardinal; Const Args : Array of const) : Cardinal;
  1542. \Description
  1543. \Errors
  1544. \SeeAlso
  1545. \end{function}
  1546. \begin{function}{IntToHex}
  1547. \Declaration
  1548. Function IntToHex(Value: integer; Digits: integer): string;
  1549. \Description
  1550. \Errors
  1551. \SeeAlso
  1552. \end{function}
  1553. \begin{function}{IntToStr}
  1554. \Declaration
  1555. Function IntToStr(Value: integer): string;
  1556. \Description
  1557. \Errors
  1558. \SeeAlso
  1559. \end{function}
  1560. \begin{function}{IsValidIdent}
  1561. \Declaration
  1562. Function IsValidIdent(const Ident: string): boolean;
  1563. \Description
  1564. \Errors
  1565. \SeeAlso
  1566. \end{function}
  1567. \begin{function}{LeftStr}
  1568. \Declaration
  1569. Function LeftStr(const S: string; Count: integer): string;
  1570. \Description
  1571. \Errors
  1572. \SeeAlso
  1573. \end{function}
  1574. \begin{function}{LoadStr}
  1575. \Declaration
  1576. Function LoadStr(Ident: integer): string;
  1577. \Description
  1578. \Errors
  1579. \SeeAlso
  1580. \end{function}
  1581. \begin{function}{LowerCase}
  1582. \Declaration
  1583. Function LowerCase(const s: string): string;
  1584. \Description
  1585. \Errors
  1586. \SeeAlso
  1587. \end{function}
  1588. \begin{functionl}{NewStr}{NewStrSys}
  1589. \Declaration
  1590. Function NewStr(const S: string): PString;
  1591. \Description
  1592. \Errors
  1593. \SeeAlso
  1594. \end{functionl}
  1595. \begin{function}{QuotedStr}
  1596. \Declaration
  1597. Function QuotedStr(const S: string): string;
  1598. \Description
  1599. \Errors
  1600. \SeeAlso
  1601. \end{function}
  1602. \begin{function}{RightStr}
  1603. \Declaration
  1604. Function RightStr(const S: string; Count: integer): string;
  1605. \Description
  1606. \Errors
  1607. \SeeAlso
  1608. \end{function}
  1609. \begin{function}{StrFmt}
  1610. \Declaration
  1611. Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
  1612. \Description
  1613. \Errors
  1614. \SeeAlso
  1615. \end{function}
  1616. \begin{function}{StrLFmt}
  1617. \Declaration
  1618. Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
  1619. \Description
  1620. \Errors
  1621. \SeeAlso
  1622. \end{function}
  1623. \begin{function}{StrToInt}
  1624. \Declaration
  1625. Function StrToInt(const s: string): integer;
  1626. \Description
  1627. \Errors
  1628. \SeeAlso
  1629. \end{function}
  1630. \begin{function}{StrToIntDef}
  1631. \Declaration
  1632. Function StrToIntDef(const S: string; Default: integer): integer;
  1633. \Description
  1634. \Errors
  1635. \SeeAlso
  1636. \end{function}
  1637. \begin{function}{Trim}
  1638. \Declaration
  1639. Function Trim(const S: string): string;
  1640. \Description
  1641. \Errors
  1642. \SeeAlso
  1643. \end{function}
  1644. \begin{function}{TrimLeft}
  1645. \Declaration
  1646. Function TrimLeft(const S: string): string;
  1647. \Description
  1648. \Errors
  1649. \SeeAlso
  1650. \end{function}
  1651. \begin{function}{TrimRight}
  1652. \Declaration
  1653. Function TrimRight(const S: string): string;
  1654. \Description
  1655. \Errors
  1656. \SeeAlso
  1657. \end{function}
  1658. \begin{function}{UpperCase}
  1659. \Declaration
  1660. Function UpperCase(const s: string): string;
  1661. \Description
  1662. \Errors
  1663. \SeeAlso
  1664. \end{function}