gegl_external_utils.pas 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  1. (*
  2. * Copyright (c) 2021-2022 Serg Shutkin
  3. *
  4. * This software is provided 'as-is', without any express or
  5. * implied warranty. In no event will the authors be held
  6. * liable for any damages arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute
  10. * it freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented;
  13. * you must not claim that you wrote the original software.
  14. * If you use this software in a product, an acknowledgment
  15. * in the product documentation would be appreciated but
  16. * is not required.
  17. *
  18. * 2. Altered source versions must be plainly marked as such,
  19. * and must not be misrepresented as being the original software.
  20. *
  21. * 3. This notice may not be removed or altered from any
  22. * source distribution.
  23. *)
  24. // Rus: требуется проверка при работе с флагами переполнения. На данный момент
  25. // проблем не возникало.
  26. // Eng: validation is required when dealing with overflow flags. At the moment
  27. // there have been no problems.
  28. unit gegl_external_Utils;
  29. {$I gegl_config.cfg}
  30. interface
  31. const
  32. // Rus: константы задаваемые при вызове geStrToInt
  33. // Eng: constants set when calling geStrToInt
  34. isByte = 0;
  35. isShortInt = 0;
  36. {$IfDef USE_CPU16}
  37. isWord = 1;
  38. isSmallInt = 1;
  39. {$EndIf}
  40. {$IfDef USE_CPU32}
  41. isLongWord = 2;
  42. isInteger = 2;
  43. {$EndIf}
  44. {$IfDef USE_CPU64}
  45. isQWord = 3;
  46. isInt64 = 3;
  47. {$EndIf}
  48. {$IfDef CPU8}
  49. maxSize = 0;
  50. {$EndIf}
  51. {$IfDef CPU16}
  52. maxSize = 1;
  53. {$EndIf}
  54. {$IfDef CPU32}
  55. maxSize = 2;
  56. {$EndIf}
  57. {$IfDef CPU64}
  58. maxSize = 3;
  59. {$EndIf}
  60. type
  61. PmaxIntVal = ^maxIntVal;
  62. PmaxUIntVal = ^maxUIntVal;
  63. {$IfDef CPU8}
  64. maxIntVal = {$IfNDef UP_CPU}ShortInt{$Else}SmallInt{$EndIf};
  65. maxUIntVal = {$IfNDef UP_CPU}Byte{$Else}Word{$EndIf};
  66. {$EndIf}
  67. {$IfDef CPU16}
  68. maxIntVal = {$IfNDef UP_CPU}SmallInt{$Else}Integer{$EndIf};
  69. maxUIntVal = {$IfNDef UP_CPU}Word{$Else}LongWord{$EndIf};
  70. {$EndIf}
  71. {$IfDef CPU32}
  72. maxIntVal = {$IfNDef UP_CPU}Int64{$Else}Integer{$EndIf};
  73. maxUIntVal = {$IfNDef UP_CPU}LongWord{$Else}QWord{$EndIf};
  74. {$EndIf}
  75. {$IfDef CPU64}
  76. maxIntVal = Int64;
  77. maxUIntVal = QWord;
  78. {$EndIf}
  79. {$IfDef USE_STRING}
  80. useString = String;
  81. {$EndIf}
  82. {$IfDef USE_ANSISTRING}
  83. useString = AnsiString;
  84. {$EndIf}
  85. {$IfDef USE_UTF8STRING}
  86. useString = UTF8String;
  87. {$EndIf}
  88. // Rus: эта функция для десятичных чисел со знаком.
  89. // Eng: this function is for signed decimal numbers.
  90. {$IfNDef UNICODESTRING_ONLI}
  91. function geCharToInt(const aStr: array of Char; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean;
  92. function geStrToInt(const Str: useString; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  93. {$EndIf}
  94. {$IfDef USE_UNICODESTRING}
  95. function geWCharToInt(const aStr: array of WideChar; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean;
  96. function geStrToInt(const Str: UnicodeString; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  97. {$EndIf}
  98. // Rus: эта функция только для десятичных чисел без знака!!!
  99. // Eng: this function is only for unsigned decimal numbers!!!
  100. {$IfNDef UNICODESTRING_ONLI}
  101. function geCharToUInt(const aStr: array of Char; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  102. function geStrToUInt(const Str: useString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  103. {$EndIf}
  104. {$IfDef USE_UNICODESTRING}
  105. function geWCharToUInt(const aStr: array of WideChar; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  106. function geStrToUInt(const Str: UnicodeString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  107. {$EndIf}
  108. // Rus: для работы с шестнадцатеричными, восьмеричными и двоичными данными.
  109. // Eng: for working with hexadecimal, octal and binary data.
  110. {$IfNDef UNICODESTRING_ONLI}
  111. function geHOBCharToUInt(const aStr: array of Char; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  112. function geHOBStrToUInt(const Str: useString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  113. {$EndIf}
  114. {$IfDef USE_UNICODESTRING}
  115. function geHOBWCharToUInt(const aStr: array of WideChar; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  116. function geHOBStrToUInt(const Str: UnicodeString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  117. {$EndIf}
  118. (* Rus: Ниже реализованы стандартные функции для перевода строк в число. Их
  119. * использование будет проще для большинства. Функции отмечены префиксом.
  120. * s_ - функции возвращают результат (если операция была неудачной, то
  121. * в результате вернётся ноль, но вы не узнаете, что операция была неудачной).
  122. * sc_ - результат функций удачная или не удачная была операция. Сам
  123. * конечный числовой результат считывайте в Value.
  124. * Eng: The standard functions for converting strings to numbers are implemented
  125. * below. Their use will be easier for most. Functions are marked with a prefix.
  126. * s_ - functions return a result (if the operation was unsuccessful, the result
  127. * will be zero, but you will not know that the operation was unsuccessful).
  128. * sc_ - the result of the functions - the operation was successful or
  129. * unsuccessful. Read the final numerical result in Value.
  130. *)
  131. // sc_ - speed + check
  132. // s_ - speed (not check)
  133. // Rus: Числа со знаком. Здесь нельзя использовать шестнадцатеричные, восьмеричные
  134. // и двоичные числа.
  135. // Eng: Signed numbers. Hexadecimal, octal and binary numbers cannot be used here.
  136. {$IfNDef UNICODESTRING_ONLI}
  137. function sc_StrToShortInt(const Str: useString; out Value: ShortInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  138. function s_StrToShortInt(const Str: useString): ShortInt; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  139. {$IfDef USE_CPU16}
  140. function sc_StrToSmallInt(const Str: useString; out Value: SmallInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // word
  141. function s_StrToSmallInt(const Str: useString): SmallInt; {$IfDef ADD_FAST}inline;{$EndIf} // word
  142. {$EndIf}
  143. {$IfDef USE_CPU32}
  144. function sc_StrToInt(const Str: useString; out Value: Integer): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  145. function s_StrToInt(const Str: useString): Integer; {$IfDef ADD_FAST}inline;{$EndIf}
  146. {$EndIf}
  147. {$IfDef USE_CPU64}
  148. function sc_StrToInt64(const Str: useString; out Value: Int64): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  149. function s_StrToInt64(const Str: useString): Int64; {$IfDef ADD_FAST}inline;{$EndIf}
  150. {$EndIf}
  151. {$EndIf}
  152. {$IfDef USE_UNICODESTRING}
  153. function sc_StrToShortInt(const Str: UnicodeString; out Value: ShortInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  154. function s_StrToShortInt(const Str: UnicodeString): ShortInt; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  155. {$IfDef USE_CPU16}
  156. function sc_StrToSmallInt(const Str: UnicodeString; out Value: SmallInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // word
  157. function s_StrToSmallInt(const Str: UnicodeString): SmallInt; {$IfDef ADD_FAST}inline;{$EndIf} // word
  158. {$EndIf}
  159. {$IfDef USE_CPU32}
  160. function sc_StrToInt(const Str: UnicodeString; out Value: Integer): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  161. function s_StrToInt(const Str: UnicodeString): Integer; {$IfDef ADD_FAST}inline;{$EndIf}
  162. {$EndIf}
  163. {$IfDef USE_CPU64}
  164. function sc_StrToInt64(const Str: UnicodeString; out Value: Int64): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  165. function s_StrToInt64(const Str: UnicodeString): Int64; {$IfDef ADD_FAST}inline;{$EndIf}
  166. {$EndIf}
  167. {$EndIf}
  168. // Rus: Числа без знака. Эти функции могут использоваться и для шестнадцатеричныи
  169. // и восьмеричных и двоичных чисел. Данные функции не должны содержать
  170. // ведущие нули для десятеричной системы счисления.
  171. // Eng: Numbers without a sign. These functions can be used for hexadecimal, octal
  172. // and binary numbers as well. These functions must not contain leading zeros
  173. // for the decimal number system.
  174. {$IfNDef UNICODESTRING_ONLI}
  175. function sc_StrToByte(const Str: useString; out Value: Byte): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  176. function s_StrToByte(const Str: useString): Byte; {$IfDef ADD_FAST}inline;{$EndIf}
  177. {$IfDef USE_CPU16}
  178. function sc_StrToWord(const Str: useString; out Value: Word): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  179. function s_StrToWord(const Str: useString): Word; {$IfDef ADD_FAST}inline;{$EndIf}
  180. {$EndIf}
  181. {$IfDef USE_CPU32}
  182. function sc_StrToLongWord(const Str: useString; out Value: LongWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  183. function s_StrToLongWord(const Str: useString): LongWord; {$IfDef ADD_FAST}inline;{$EndIf}
  184. {$EndIf}
  185. {$IfDef USE_CPU64}
  186. function sc_StrToQWord(const Str: useString; out Value: QWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  187. function s_StrToQWord(const Str: useString): QWord; {$IfDef ADD_FAST}inline;{$EndIf}
  188. {$EndIf}
  189. {$EndIf}
  190. {$IfDef USE_UNICODESTRING}
  191. function sc_StrToByte(const Str: UnicodeString; out Value: Byte): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  192. function s_StrToByte(const Str: UnicodeString): Byte; {$IfDef ADD_FAST}inline;{$EndIf}
  193. {$IfDef USE_CPU16}
  194. function sc_StrToWord(const Str: UnicodeString; out Value: Word): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  195. function s_StrToWord(const Str: UnicodeString): Word; {$IfDef ADD_FAST}inline;{$EndIf}
  196. {$EndIf}
  197. {$IfDef USE_CPU32}
  198. function sc_StrToLongWord(const Str: UnicodeString; out Value: LongWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  199. function s_StrToLongWord(const Str: UnicodeString): LongWord; {$IfDef ADD_FAST}inline;{$EndIf}
  200. {$EndIf}
  201. {$IfDef USE_CPU64}
  202. function sc_StrToQWord(const Str: UnicodeString; out Value: QWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  203. function s_StrToQWord(const Str: UnicodeString): QWord; {$IfDef ADD_FAST}inline;{$EndIf}
  204. {$EndIf}
  205. {$EndIf}
  206. implementation
  207. {$Goto on}
  208. const
  209. dataHex: array[0..54] of Byte = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 16, 16, 16, 16, 16,
  210. 16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  211. 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 16, 16, 16, 16,
  212. 16, 10, 11, 12, 13, 14, 15);
  213. type
  214. PgeUseParametr = ^geUseParametr;
  215. geUseParametr = record
  216. maxLen: LongWord;
  217. maxNumDiv10: maxUIntVal;
  218. maxNumeric: maxUIntVal;
  219. end;
  220. PgeHOBParameter = ^geHOBParameter;
  221. geHOBParameter = record
  222. maxLen16, maxLen8, maxLen2: maxUIntVal;
  223. end;
  224. var
  225. allIntParametr, allUIntParametr: array[0..7] of geUseParametr;
  226. allHOBParametr: array[0..3] of geHOBParameter;
  227. // Rus: выставляем необходимые параметры. Иначе geStrToInt работать не будет.
  228. // В блоке инициализации.
  229. // Eng: set the required parameters. Otherwise geStrToInt won't work.
  230. // in the initialization block.
  231. procedure SetNumberParametr;
  232. begin
  233. allUIntParametr[isByte].maxLen := 3;
  234. allUIntParametr[isByte].maxNumeric := 255;
  235. allUIntParametr[isByte].maxNumDiv10 := 25;
  236. allIntParametr[isShortInt].maxLen := 4;
  237. allIntParametr[isShortInt].maxNumeric := 127;
  238. allIntParametr[isShortInt].maxNumDiv10 := 12;
  239. {$IfDef USE_CPU16}
  240. allUIntParametr[isWord].maxLen := 5;
  241. allUIntParametr[isWord].maxNumeric := 65535;
  242. allUIntParametr[isWord].maxNumDiv10 := 6553;
  243. allIntParametr[isSmallInt].maxLen := 6;
  244. allIntParametr[isSmallInt].maxNumeric := 32767;
  245. allIntParametr[isSmallInt].maxNumDiv10 := 3276;
  246. {$EndIf}
  247. {$IfDef USE_CPU32}
  248. allUIntParametr[isLongWord].maxLen := 10;
  249. allUIntParametr[isLongWord].maxNumeric := 4294967295;
  250. allUIntParametr[isLongWord].maxNumDiv10 := 429496729;
  251. allIntParametr[isInteger].maxLen := 11;
  252. allIntParametr[isInteger].maxNumeric := 2147483647;
  253. allIntParametr[isInteger].maxNumDiv10 := 214748364;
  254. {$EndIf}
  255. {$IfDef USE_CPU64}
  256. allUIntParametr[isQWord].maxLen := 20;
  257. allUIntParametr[isQWord].maxNumeric := 18446744073709551615;
  258. allUIntParametr[isQWord].maxNumDiv10 := 1844674407370955161;
  259. allIntParametr[isInt64].maxLen := 20;
  260. allIntParametr[isInt64].maxNumeric := 9223372036854775807;
  261. allIntParametr[isInt64].maxNumDiv10 := 922337203685477580;
  262. {$EndIf}
  263. allHOBParametr[isByte].maxLen16 := 3;
  264. allHOBParametr[isByte].maxLen8 := 4;
  265. allHOBParametr[isByte].maxLen2 := 9;
  266. {$IfDef USE_CPU16}
  267. allHOBParametr[isWord].maxLen16 := 5;
  268. allHOBParametr[isWord].maxLen8 := 7;
  269. allHOBParametr[isWord].maxLen2 := 17;
  270. {$EndIf}
  271. {$IfDef USE_CPU32}
  272. allHOBParametr[isLongWord].maxLen16 := 9;
  273. allHOBParametr[isLongWord].maxLen8 := 12;
  274. allHOBParametr[isLongWord].maxLen2 := 33;
  275. {$EndIf}
  276. {$IfDef USE_CPU64}
  277. allHOBParametr[isQWord].maxLen16 := 17;
  278. allHOBParametr[isQWord].maxLen8 := 23;
  279. allHOBParametr[isQWord].maxLen2 := 65;
  280. {$EndIf}
  281. end;
  282. {$IfNDef UNICODESTRING_ONLI}
  283. function geStrToInt(const Str: useString; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  284. begin
  285. Result := geCharToInt(Str[1..Length(Str)], Value, Size);
  286. end;
  287. function geStrToUInt(const Str: useString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  288. begin
  289. Result := geCharToUInt(Str[1..Length(Str)], Value, Size);
  290. end;
  291. function geHOBStrToUInt(const Str: useString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  292. begin
  293. Result := geHOBCharToUInt(Str[1..Length(Str)], Value, Size);
  294. end;
  295. function sc_StrToShortInt(const Str: useString; out Value: ShortInt): Boolean;
  296. var
  297. n: maxIntVal;
  298. begin
  299. Result := geCharToInt(Str[1..Length(Str)], n, isShortInt);
  300. Value := n;
  301. end;
  302. function s_StrToShortInt(const Str: useString): ShortInt;
  303. var
  304. n: maxIntVal;
  305. begin
  306. geCharToInt(Str[1..Length(Str)], n, isShortInt);
  307. Result := n;
  308. end;
  309. {$IfDef USE_CPU16}
  310. function sc_StrToSmallInt(const Str: useString; out Value: SmallInt): Boolean;
  311. var
  312. n: maxIntVal;
  313. begin
  314. Result := geCharToInt(Str[1..Length(Str)], n, isSmallInt);
  315. Value := n;
  316. end;
  317. function s_StrToSmallInt(const Str: useString): SmallInt;
  318. var
  319. n: maxIntVal;
  320. begin
  321. geCharToInt(Str[1..Length(Str)], n, isSmallInt);
  322. Result := n;
  323. end;
  324. {$EndIf}
  325. {$IfDef USE_CPU32}
  326. function sc_StrToInt(const Str: useString; out Value: Integer): Boolean;
  327. var
  328. n: maxIntVal;
  329. begin
  330. Result := geCharToInt(Str[1..Length(Str)], n, isInteger);
  331. Value := n;
  332. end;
  333. function s_StrToInt(const Str: useString): Integer;
  334. var
  335. n: maxIntVal;
  336. begin
  337. geCharToInt(Str[1..Length(Str)], n, isInteger);
  338. Result := n;
  339. end;
  340. {$EndIf}
  341. {$IfDef USE_CPU64}
  342. function sc_StrToInt64(const Str: useString; out Value: Int64): Boolean;
  343. begin
  344. Result := geCharToInt(Str[1..Length(Str)], Value, isInt64);
  345. end;
  346. function s_StrToInt64(const Str: useString): Int64;
  347. begin
  348. geCharToInt(Str[1..Length(Str)], Result, isInt64);
  349. end;
  350. {$EndIf}
  351. function sc_StrToByte(const Str: useString; out Value: Byte): Boolean;
  352. var
  353. n: maxUIntVal;
  354. begin
  355. n := Byte(Str[1]);
  356. if (n = 48) or ((n >= 36) and (n <= 38)) then
  357. Result := geHOBCharToUInt(Str[1..Length(Str)], n, isByte)
  358. else
  359. Result := geCharToUInt(Str[1..Length(Str)], n, isByte);
  360. Value := n;
  361. end;
  362. function s_StrToByte(const Str: useString): Byte;
  363. var
  364. n: maxUIntVal;
  365. begin
  366. n := Byte(Str[1]);
  367. if (n = 48) or ((n >= 36) and (n <= 38)) then
  368. geHOBCharToUInt(Str[1..Length(Str)], n, isByte)
  369. else
  370. geCharToUInt(Str[1..Length(Str)], n, isByte);
  371. Result := n;
  372. end;
  373. {$IfDef USE_CPU16}
  374. function sc_StrToWord(const Str: useString; out Value: Word): Boolean;
  375. var
  376. n: maxUIntVal;
  377. begin
  378. n := Byte(Str[1]);
  379. if (n = 48) or ((n >= 36) and (n <= 38)) then
  380. Result := geHOBCharToUInt(Str[1..Length(Str)], n, isWord)
  381. else
  382. Result := geCharToUInt(Str[1..Length(Str)], n, isWord);
  383. Value := n;
  384. end;
  385. function s_StrToWord(const Str: useString): Word;
  386. var
  387. n: maxUIntVal;
  388. begin
  389. n := Byte(Str[1]);
  390. if (n = 48) or ((n >= 36) and (n <= 38)) then
  391. geHOBCharToUInt(Str[1..Length(Str)], n, isWord)
  392. else
  393. geCharToUInt(Str[1..Length(Str)], n, isWord);
  394. Result := n;
  395. end;
  396. {$EndIf}
  397. {$IfDef USE_CPU32}
  398. function sc_StrToLongWord(const Str: useString; out Value: LongWord): Boolean;
  399. var
  400. n: maxUIntVal;
  401. begin
  402. n := Byte(Str[1]);
  403. if (n = 48) or ((n >= 36) and (n <= 38)) then
  404. Result := geHOBCharToUInt(Str[1..Length(Str)], n, isLongWord)
  405. else
  406. Result := geCharToUInt(Str[1..Length(Str)], n, isLongWord);
  407. Value := n;
  408. end;
  409. function s_StrToLongWord(const Str: useString): LongWord;
  410. var
  411. n: maxUIntVal;
  412. begin
  413. n := Byte(Str[1]);
  414. if (n = 48) or ((n >= 36) and (n <= 38)) then
  415. geHOBCharToUInt(Str[1..Length(Str)], n, isLongWord)
  416. else
  417. geCharToUInt(Str[1..Length(Str)], n, isLongWord);
  418. Result := n;
  419. end;
  420. {$EndIf}
  421. {$IfDef USE_CPU64}
  422. function sc_StrToQWord(const Str: useString; out Value: QWord): Boolean;
  423. var
  424. n: maxUIntVal;
  425. begin
  426. n := Byte(Str[1]);
  427. if (n = 48) or ((n >= 36) and (n <= 38)) then
  428. Result := geHOBCharToUInt(Str[1..Length(Str)], Value, isQWord)
  429. else
  430. Result := geCharToUInt(Str[1..Length(Str)], Value, isQWord);
  431. end;
  432. function s_StrToQWord(const Str: useString): QWord;
  433. var
  434. n: maxUIntVal;
  435. begin
  436. n := Byte(Str[1]);
  437. if (n = 48) or ((n >= 36) and (n <= 38)) then
  438. geHOBCharToUInt(Str[1..Length(Str)], Result, isQWord)
  439. else
  440. geCharToUInt(Str[1..Length(Str)], Result, isQWord);
  441. end;
  442. {$EndIf}
  443. function geCharToUInt(const aStr: array of Char; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  444. var
  445. lenStr, i: maxUIntVal;
  446. m, n, z: maxUIntVal;
  447. useParametr: PgeUseParametr;
  448. correct: maxUIntVal = 0;
  449. begin
  450. {$push}
  451. {$Q-}{$R-}
  452. Result := False;
  453. Value := 0;
  454. if Size > maxSize then
  455. Exit;
  456. lenStr := Length(aStr);
  457. if lenStr = 0 then
  458. exit;
  459. m := Byte(aStr[0]);
  460. i := 1;
  461. while m = 48 do
  462. begin
  463. if (lenStr - correct) = 1 then
  464. begin
  465. Result := True;
  466. exit;
  467. end;
  468. m := Byte(aStr[i]);
  469. inc(i);
  470. inc(correct);
  471. end;
  472. m := m - 48;
  473. if m > 9 then
  474. exit;
  475. if (lenStr - correct) = 1 then
  476. begin
  477. Value := m;
  478. Result := true;
  479. Exit;
  480. end;
  481. useParametr := @allUIntParametr[Size];
  482. if lenStr > useParametr^.maxLen then
  483. Exit;
  484. while i < lenStr - 1 do
  485. begin
  486. n := (Byte(aStr[i]) - 48);
  487. if n > 9 then
  488. Exit;
  489. m := m * 10 + n;
  490. inc(i);
  491. end;
  492. if m > useParametr^.maxNumDiv10 then
  493. exit;
  494. m := m * 10;
  495. z := Byte(aStr[i]) - 48;
  496. if z > 9 then
  497. exit;
  498. n := useParametr^.maxNumeric - m;
  499. if z > n then
  500. exit;
  501. Value := m + z;
  502. Result := true;
  503. {$pop}
  504. end;
  505. function geHOBCharToUInt(const aStr: array of Char; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  506. var
  507. lenStr, i: maxUIntVal;
  508. m, n, nshl, z: maxUIntVal;
  509. Pnshl: PmaxUIntVal;
  510. correct: maxUIntVal = 0;
  511. useParametr: PgeHOBParameter;
  512. begin
  513. {$push}
  514. {$Q-}{$R-}
  515. Result := False;
  516. Value := 0;
  517. if Size > maxSize then
  518. exit;
  519. lenStr := Length(aStr);
  520. if lenStr = 0 then
  521. exit;
  522. m := Byte(aStr[0]);
  523. n := Byte(aStr[1]);
  524. i := 1;
  525. if m = 48 then
  526. begin
  527. if n > 97 then
  528. n := n - 32;
  529. m := 38;
  530. if (n = 66) or (n = 88) or (n = 79) then
  531. begin
  532. correct := 1;
  533. i := 2;
  534. if n = 66 then
  535. begin
  536. m := 37;
  537. end
  538. else
  539. if n = 88 then
  540. m := 36;
  541. n := Byte(aStr[2]);
  542. end;
  543. end;
  544. while n = 48 do
  545. begin
  546. if (lenStr - correct) = 1 then
  547. begin
  548. Result := True;
  549. exit;
  550. end;
  551. inc(i);
  552. inc(correct);
  553. n := Byte(aStr[i]);
  554. end;
  555. n := n - 48;
  556. useParametr := @allHOBParametr[Size];
  557. if m = 38 then
  558. begin
  559. if (lenStr - correct) > useParametr^.maxLen8 then
  560. exit;
  561. if useParametr^.maxLen8 = (lenStr - correct) then
  562. if (Size = isByte) or (Size = isLongWord) then
  563. begin
  564. if n > 3 then
  565. exit;
  566. end
  567. else
  568. if n > 1 then
  569. exit;
  570. nshl := 3;
  571. z := 7;
  572. end
  573. else
  574. if m = 37 then
  575. begin
  576. if (lenStr - correct) > useParametr^.maxLen2 then
  577. exit;
  578. nshl := 1;
  579. z := 1;
  580. end;
  581. if m = 36 then
  582. begin
  583. if (lenStr - correct) > useParametr^.maxLen16 then
  584. exit;
  585. m := 0;
  586. while i <= lenStr - 1 do
  587. begin
  588. m := m shl 4;
  589. n := Byte(aStr[i]) - 48;
  590. if n > 55 then
  591. exit;
  592. n := dataHex[n];
  593. if n = 16 then
  594. exit;
  595. m := m + n;
  596. inc(i);
  597. end;
  598. end
  599. else begin
  600. Pnshl := @nshl;
  601. m := n;
  602. if m > z then
  603. exit;
  604. inc(i);
  605. while i <= lenStr - 1 do
  606. begin
  607. m := m shl Pnshl^;
  608. n := Byte(aStr[i]) - 48;
  609. if n > z then
  610. exit;
  611. m := m + n;
  612. inc(i);
  613. end;
  614. end;
  615. Value := m;
  616. Result := true;
  617. {$pop}
  618. end;
  619. function geCharToInt(const aStr: array of char; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean;
  620. var
  621. lenStr, i: maxUIntVal;
  622. m, n, z: maxUIntVal;
  623. useParametr: PgeUseParametr;
  624. IntMinus: Boolean = False;
  625. correct: maxUIntVal = 0;
  626. label
  627. jmpEndStr;
  628. begin
  629. {$push}
  630. {$Q-}{$R-}
  631. Result := False;
  632. Value := 0;
  633. if Size > maxSize then
  634. Exit;
  635. lenStr := Length(aStr);
  636. if lenStr = 0 then
  637. exit;
  638. m := Byte(aStr[0]);
  639. i := 1;
  640. if m = 45 then
  641. begin
  642. if lenStr = 1 then
  643. exit;
  644. IntMinus := True;
  645. m := Byte(aStr[i]);
  646. inc(i);
  647. end;
  648. while m = 48 do
  649. begin
  650. if (lenStr - correct) = 1 then
  651. begin
  652. Result := True;
  653. exit;
  654. end;
  655. m := Byte(aStr[i]);
  656. inc(i);
  657. inc(correct);
  658. end;
  659. m := m - 48;
  660. if m > 9 then
  661. exit;
  662. useParametr := @allIntParametr[Size];
  663. if i > lenStr - 1 then
  664. begin
  665. z := 0;
  666. goto jmpEndStr;
  667. end;
  668. if (lenStr - correct) > useParametr^.maxLen then
  669. Exit;
  670. while i < lenStr - 1 do
  671. begin
  672. n := (Byte(aStr[i]) - 48);
  673. if n > 9 then
  674. Exit;
  675. m := m * 10 + n;
  676. inc(i);
  677. end;
  678. if m > useParametr^.maxNumDiv10 then
  679. exit;
  680. m := m * 10;
  681. z := Byte(aStr[i]) - 48;
  682. if z > 9 then
  683. exit;
  684. jmpEndStr:
  685. if IntMinus then
  686. n := useParametr^.maxNumeric + 1 - m
  687. else
  688. n := useParametr^.maxNumeric - m;
  689. if z > n then
  690. exit;
  691. if IntMinus then
  692. Value := - m - z
  693. else
  694. Value := m + z;
  695. Result := true;
  696. {$pop}
  697. end;
  698. {$EndIf}
  699. {$IfDef USE_UNICODESTRING}
  700. function geStrToInt(const Str: UnicodeString; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  701. begin
  702. Result := geWCharToInt(Str[1..Length(Str)], Value, Size);
  703. end;
  704. function geStrToUInt(const Str: UnicodeString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  705. begin
  706. Result := geWCharToUInt(Str[1..Length(Str)], Value, Size);;
  707. end;
  708. function geHOBStrToUInt(const Str: UnicodeString; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean; inline;
  709. begin
  710. Result := geHOBWCharToUInt(Str[1..Length(Str)], Value, Size);
  711. end;
  712. function sc_StrToShortInt(const Str: UnicodeString; out Value: ShortInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  713. var
  714. n: maxIntVal;
  715. begin
  716. Result := geWCharToInt(Str[1..Length(Str)], n, isShortInt);
  717. Value := n;
  718. end;
  719. function s_StrToShortInt(const Str: UnicodeString): ShortInt; {$IfDef ADD_FAST}inline;{$EndIf} // byte
  720. var
  721. n: maxIntVal;
  722. begin
  723. geWCharToInt(Str[1..Length(Str)], n, isShortInt);
  724. Result := n;
  725. end;
  726. {$IfDef USE_CPU16}
  727. function sc_StrToSmallInt(const Str: UnicodeString; out Value: SmallInt): Boolean; {$IfDef ADD_FAST}inline;{$EndIf} // word
  728. var
  729. n: maxIntVal;
  730. begin
  731. Result := geWCharToInt(Str[1..Length(Str)], n, isSmallInt);
  732. Value := n;
  733. end;
  734. function s_StrToSmallInt(const Str: UnicodeString): SmallInt; {$IfDef ADD_FAST}inline;{$EndIf} // word
  735. var
  736. n: maxIntVal;
  737. begin
  738. geWCharToInt(Str[1..Length(Str)], n, isSmallInt);
  739. Result := n;
  740. end;
  741. {$EndIf}
  742. {$IfDef USE_CPU32}
  743. function sc_StrToInt(const Str: UnicodeString; out Value: Integer): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  744. var
  745. n: maxIntVal;
  746. begin
  747. Result := geWCharToInt(Str[1..Length(Str)], n, isInteger);
  748. Value := n;
  749. end;
  750. function s_StrToInt(const Str: UnicodeString): Integer; {$IfDef ADD_FAST}inline;{$EndIf}
  751. var
  752. n: maxIntVal;
  753. begin
  754. geWCharToInt(Str[1..Length(Str)], n, isInteger);
  755. Result := n;
  756. end;
  757. {$EndIf}
  758. {$IfDef USE_CPU64}
  759. function sc_StrToInt64(const Str: UnicodeString; out Value: Int64): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  760. begin
  761. Result := geWCharToInt(Str[1..Length(Str)], Value, isInt64);
  762. end;
  763. function s_StrToInt64(const Str: UnicodeString): Int64; {$IfDef ADD_FAST}inline;{$EndIf}
  764. begin
  765. geWCharToInt(Str[1..Length(Str)], Result, isInt64);
  766. end;
  767. {$EndIf}
  768. function sc_StrToByte(const Str: UnicodeString; out Value: Byte): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  769. var
  770. n: maxUIntVal;
  771. begin
  772. n := Byte(Str[1]);
  773. if (n = 48) or ((n >= 36) and (n <= 38)) then
  774. Result := geHOBWCharToUInt(Str[1..Length(Str)], n, isByte)
  775. else
  776. Result := geWCharToUInt(Str[1..Length(Str)], n, isByte);
  777. Value := n;
  778. end;
  779. function s_StrToByte(const Str: UnicodeString): Byte; {$IfDef ADD_FAST}inline;{$EndIf}
  780. var
  781. n: maxUIntVal;
  782. begin
  783. n := Byte(Str[1]);
  784. if (n = 48) or ((n >= 36) and (n <= 38)) then
  785. geHOBWCharToUInt(Str[1..Length(Str)], n, isByte)
  786. else
  787. geWCharToUInt(Str[1..Length(Str)], n, isByte);
  788. Result := n;
  789. end;
  790. {$IfDef USE_CPU16}
  791. function sc_StrToWord(const Str: UnicodeString; out Value: Word): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  792. var
  793. n: maxUIntVal;
  794. begin
  795. n := Byte(Str[1]);
  796. if (n = 48) or ((n >= 36) and (n <= 38)) then
  797. Result := geHOBWCharToUInt(Str[1..Length(Str)], n, isWord)
  798. else
  799. Result := geWCharToUInt(Str[1..Length(Str)], n, isWord);
  800. Value := n;
  801. end;
  802. function s_StrToWord(const Str: UnicodeString): Word; {$IfDef ADD_FAST}inline;{$EndIf}
  803. var
  804. n: maxUIntVal;
  805. begin
  806. n := Byte(Str[1]);
  807. if (n = 48) or ((n >= 36) and (n <= 38)) then
  808. geHOBWCharToUInt(Str[1..Length(Str)], n, isWord)
  809. else
  810. geWCharToUInt(Str[1..Length(Str)], n, isWord);
  811. Result := n;
  812. end;
  813. {$EndIf}
  814. {$IfDef USE_CPU32}
  815. function sc_StrToLongWord(const Str: UnicodeString; out Value: LongWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  816. var
  817. n: maxUIntVal;
  818. begin
  819. n := Byte(Str[1]);
  820. if (n = 48) or ((n >= 36) and (n <= 38)) then
  821. Result := geHOBWCharToUInt(Str[1..Length(Str)], n, isLongWord)
  822. else
  823. Result := geWCharToUInt(Str[1..Length(Str)], n, isLongWord);
  824. Value := n;
  825. end;
  826. function s_StrToLongWord(const Str: UnicodeString): LongWord; {$IfDef ADD_FAST}inline;{$EndIf}
  827. var
  828. n: maxUIntVal;
  829. begin
  830. n := Byte(Str[1]);
  831. if (n = 48) or ((n >= 36) and (n <= 38)) then
  832. geHOBWCharToUInt(Str[1..Length(Str)], n, isLongWord)
  833. else
  834. geWCharToUInt(Str[1..Length(Str)], n, isLongWord);
  835. Result := n;
  836. end;
  837. {$EndIf}
  838. {$IfDef USE_CPU64}
  839. function sc_StrToQWord(const Str: UnicodeString; out Value: QWord): Boolean; {$IfDef ADD_FAST}inline;{$EndIf}
  840. var
  841. n: maxUIntVal;
  842. begin
  843. n := Byte(Str[1]);
  844. if (n = 48) or ((n >= 36) and (n <= 38)) then
  845. Result := geHOBWCharToUInt(Str[1..Length(Str)], Value, isQWord)
  846. else
  847. Result := geWCharToUInt(Str[1..Length(Str)], Value, isQWord);
  848. end;
  849. function s_StrToQWord(const Str: UnicodeString): QWord; {$IfDef ADD_FAST}inline;{$EndIf}
  850. var
  851. n: maxUIntVal;
  852. begin
  853. n := Byte(Str[1]);
  854. if (n = 48) or ((n >= 36) and (n <= 38)) then
  855. geHOBWCharToUInt(Str[1..Length(Str)], Result, isQWord)
  856. else
  857. geWCharToUInt(Str[1..Length(Str)], Result, isQWord);
  858. end;
  859. {$EndIf}
  860. function geWCharToUInt(const aStr: array of WideChar; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  861. var
  862. lenStr, i: maxUIntVal;
  863. m, n, z: maxUIntVal;
  864. useParametr: PgeUseParametr;
  865. correct: maxUIntVal = 0;
  866. begin
  867. {$push}
  868. {$Q-}{$R-}
  869. Result := False;
  870. Value := 0;
  871. if Size > maxSize then
  872. Exit;
  873. lenStr := Length(aStr);
  874. if lenStr = 0 then
  875. exit;
  876. m := Word(aStr[0]);
  877. i := 0;
  878. while m = 48 do
  879. begin
  880. if (lenStr - correct) = 1 then
  881. begin
  882. Result := True;
  883. exit;
  884. end;
  885. m := Word(aStr[i]);
  886. inc(i);
  887. inc(correct);
  888. end;
  889. m := m - 48;
  890. if m > 9 then
  891. exit;
  892. if (lenStr - correct) = 1 then
  893. begin
  894. Value := m;
  895. Result := true;
  896. Exit;
  897. end;
  898. useParametr := @allUIntParametr[Size];
  899. if lenStr > useParametr^.maxLen then
  900. Exit;
  901. while i < lenStr - 1 do
  902. begin
  903. n := (Word(aStr[i]) - 48);
  904. if n > 9 then
  905. Exit;
  906. m := m * 10 + n;
  907. inc(i);
  908. end;
  909. if m > useParametr^.maxNumDiv10 then
  910. exit;
  911. m := m * 10;
  912. z := Word(aStr[i]) - 48;
  913. if z > 9 then
  914. exit;
  915. n := useParametr^.maxNumeric - m;
  916. if z > n then
  917. exit;
  918. Value := m + z;
  919. Result := true;
  920. {$pop}
  921. end;
  922. function geHOBWCharToUInt(const aStr: array of WideChar; out Value: maxUIntVal; Size: maxIntVal = maxSize): Boolean;
  923. var
  924. lenStr, i: maxUIntVal;
  925. m, n, nshl, z: maxUIntVal;
  926. Pnshl: PmaxUIntVal;
  927. correct: maxUIntVal = 0;
  928. useParametr: PgeHOBParameter;
  929. begin
  930. {$push}
  931. {$Q-}{$R-}
  932. Result := False;
  933. Value := 0;
  934. if Size > maxSize then
  935. exit;
  936. lenStr := Length(aStr);
  937. if lenStr = 0 then
  938. exit;
  939. m := Word(aStr[0]);
  940. n := Word(aStr[1]);
  941. i := 1;
  942. if m = 48 then
  943. begin
  944. if lenStr = 1 then
  945. begin
  946. Result := True;
  947. exit;
  948. end;
  949. if n > 97 then
  950. n := n - 32;
  951. m := 38;
  952. if (n = 66) or (n = 88) or (n = 79) then
  953. begin
  954. correct := 1;
  955. i := 3;
  956. if n = 66 then
  957. begin
  958. m := 37;
  959. end
  960. else
  961. if n = 88 then
  962. m := 36;
  963. n := Word(aStr[2]);
  964. end;
  965. end;
  966. while n = 48 do
  967. begin
  968. if (lenStr - correct) = 1 then
  969. begin
  970. Result := True;
  971. exit;
  972. end;
  973. inc(i);
  974. inc(correct);
  975. n := Word(aStr[i]);
  976. end;
  977. n := n - 48;
  978. useParametr := @allHOBParametr[Size];
  979. if m = 38 then
  980. begin
  981. if (lenStr - correct) > useParametr^.maxLen8 then
  982. exit;
  983. if useParametr^.maxLen8 = (lenStr - correct) then
  984. if (Size = isByte) or (Size = isLongWord) then
  985. begin
  986. if n > 3 then
  987. exit;
  988. end
  989. else
  990. if n > 1 then
  991. exit;
  992. nshl := 3;
  993. z := 7;
  994. end
  995. else
  996. if m = 37 then
  997. begin
  998. if (lenStr - correct) > useParametr^.maxLen2 then
  999. exit;
  1000. nshl := 1;
  1001. z := 1;
  1002. end;
  1003. if m = 36 then
  1004. begin
  1005. if (lenStr - correct) > useParametr^.maxLen16 then
  1006. exit;
  1007. m := 0;
  1008. while i <= lenStr do
  1009. begin
  1010. m := m shl 4;
  1011. n := Word(aStr[i]) - 48;
  1012. if n > 55 then
  1013. exit;
  1014. n := dataHex[n];
  1015. if n = 16 then
  1016. exit;
  1017. m := m + n;
  1018. inc(i);
  1019. end;
  1020. end
  1021. else begin
  1022. Pnshl := @nshl;
  1023. m := n;
  1024. if m > z then
  1025. exit;
  1026. inc(i);
  1027. while i <= lenStr do
  1028. begin
  1029. m := m shl Pnshl^;
  1030. n := Word(aStr[i]) - 48;
  1031. if n > z then
  1032. exit;
  1033. m := m + n;
  1034. inc(i);
  1035. end;
  1036. end;
  1037. Value := m;
  1038. Result := true;
  1039. {$pop}
  1040. end;
  1041. function geWCharToInt(const aStr: array of WideChar; out Value: maxIntVal; Size: maxIntVal = maxSize): Boolean;
  1042. var
  1043. lenStr, i: maxUIntVal;
  1044. m, n, z: maxUIntVal;
  1045. useParametr: PgeUseParametr;
  1046. IntMinus: Boolean = False;
  1047. correct: maxUIntVal = 0;
  1048. label
  1049. jmpEndStr, loopZero;
  1050. begin
  1051. {$push}
  1052. {$Q-}{$R-}
  1053. Result := False;
  1054. Value := 0;
  1055. if Size > maxSize then
  1056. Exit;
  1057. lenStr := Length(aStr);
  1058. if lenStr = 0 then
  1059. exit;
  1060. m := Word(aStr[0]);
  1061. if m > 57 then
  1062. Exit;
  1063. if (lenStr = 1) and (m = 48) then
  1064. begin
  1065. Result := True;
  1066. exit;
  1067. end;
  1068. i := 1;
  1069. if m = 45 then
  1070. begin
  1071. if lenStr = 1 then
  1072. exit;
  1073. IntMinus := True;
  1074. m := Word(aStr[i]);
  1075. inc(i);
  1076. end;
  1077. loopZero:
  1078. if m = 48 then
  1079. begin
  1080. inc(i);
  1081. inc(correct);
  1082. m := Word(aStr[i]);
  1083. goto loopZero;
  1084. end;
  1085. inc(i);
  1086. m := m - 48;
  1087. if m > 9 then
  1088. exit;
  1089. useParametr := @allIntParametr[Size];
  1090. if i > lenStr - 1 then
  1091. begin
  1092. z := 0;
  1093. goto jmpEndStr;
  1094. end;
  1095. if (lenStr - correct) > useParametr^.maxLen then
  1096. Exit;
  1097. while i < lenStr - 1 do
  1098. begin
  1099. n := (Word(aStr[i]) - 48);
  1100. if n > 9 then
  1101. Exit;
  1102. m := m * 10 + n;
  1103. inc(i);
  1104. end;
  1105. if m > useParametr^.maxNumDiv10 then
  1106. exit;
  1107. m := m * 10;
  1108. z := Word(aStr[i]) - 48;
  1109. if z > 9 then
  1110. exit;
  1111. jmpEndStr:
  1112. if IntMinus then
  1113. n := useParametr^.maxNumeric + 1 - m
  1114. else
  1115. n := useParametr^.maxNumeric - m;
  1116. if z > n then
  1117. exit;
  1118. if IntMinus then
  1119. Value := - m - z
  1120. else
  1121. Value := m + z;
  1122. Result := true;
  1123. {$pop}
  1124. end;
  1125. {$EndIf}
  1126. initialization
  1127. SetNumberParametr;
  1128. end.