sysutils.tex 79 KB

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