FichteFoll

IniEx 1.1

Mar 18th, 2011
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 23.98 KB | None | 0 0
  1. #include-once
  2.  
  3. ; #INDEX# =======================================================================================================================
  4. ; Title .........: IniEx (1.1)
  5. ; Date ..........: 18.03.2011
  6. ; AutoIt Version : 3.3 + (development version = 3.3.6.0)
  7. ; Language ......: English
  8. ; Description ...: Extra functions for an extended ini support:
  9. ;                  - Functions to change the ini's encoding format and allow to use
  10. ;                    unicode for all ini-functions, prefered UTF-16 Little Endian since it's the fastest in AutoIt
  11. ;                  - Functions to read and write a whole ini into or from one three-dimensional array; also from a string
  12. ;                  - Functions to read keys, sections and sectionnames from a string instead of a file
  13. ; Remarks .......:
  14. ; Link ..........: http://www.autoitscript.com/forum/topic/125163-iniex-udf/
  15. ; Author ........: FichteFoll
  16. ; ===============================================================================================================================
  17.  
  18.  
  19. ; #CHANGELOG# ===================================================================================================================
  20. ; # 1.1
  21. ;     - Changed: Fully imitates AutoIt's ini syntax using regex and parsing them by line
  22. ;                (involves all _IniRead*FromString functions)
  23. ; ===============================================================================================================================
  24.  
  25. ; #CURRENT# =====================================================================================================================
  26. ; _IniConvertToUnicode              Converts encoding format of a text file to UTF-16 Little Endian
  27. ; _IniConvertToANSI                 Converts encoding format of a text file to ANSI
  28. ; _IniReadToArray                   Returns the whole ini file into one array with three dimensions
  29. ; _IniWriteFromArray                Writes or creates an Ini out of an array
  30. ; _IniReadFromString                Returns the value of a key in a specific section of an ini-formatted string
  31. ; _IniReadSectionNamesFromString    Returns all keys and its values from a given section name of an ini-formatted string
  32. ; _IniReadSectionFromString         Returns all section names of an ini-formatted string
  33. ; _IniReadToArrayFromString         Returns the whole ini file into one array with three dimensions
  34. ; ===============================================================================================================================
  35.  
  36. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  37. ; __StringEscapeRegExp
  38. ; ===============================================================================================================================
  39.  
  40. ; ###############################################################################################################################
  41.  
  42. ; ###############################################################################################################################
  43.  
  44. ;#Function# =====================================================================================================================
  45. ; Name............: _IniConvertToUnicode
  46. ; Description.....: Converts encoding format of a text file to UTF-16 Little Endian
  47. ; Syntax..........: _IniConvertToUnicode($szFile, $fCreate = True)
  48. ; Parameters......:
  49. ;                   $szFile      - Path to text file (won't work with binary encoded files)
  50. ;                   $fCreate     - [optional]  The File will be created if it does not exist (default)
  51. ; Return values ..:
  52. ;                   Success      - Returns 1 - sets @extended = 1 if the file is already encoded correctly
  53. ;                   Failure      - Returns 0 - sets @error
  54. ;                                              | 1 - The file does not exist (requires $fCreate = False)
  55. ;                                              | 2 - The file is not a text file
  56. ;                                              | 3 - Reading the file failed
  57. ;                                              | 4 - Opening the file with unicode failed
  58. ;                                              | 5 - Writing the file with unicode failed
  59. ; Author .........: FichteFoll
  60. ; Remarks ........: Use the related functions and _IniReadToArray or _IniWriteFromArray to access a unicode-formatted ini.
  61. ;                   If the file does not exist it will be created.
  62. ; Related ........: FileGetEncoding, IniRead, IniWrite, IniReadSection, IniWriteSection, IniReadSectionNames
  63. ; Link ...........; See on top
  64. ; Example ........; _IniConvertToUnicode("c:/file.ini")
  65. ; ===============================================================================================================================
  66. Func _IniConvertToUnicode($szFile, $fCreate = True)
  67.     If Not FileExists($szFile) And $fCreate = False Then Return SetError(1)
  68.  
  69.     Local $iEncoding, $szContent, $f
  70.     $iEncoding = FileGetEncoding($szFile)
  71.  
  72.     Switch $iEncoding
  73.         Case 32
  74.             Return SetExtended(1, 1) ; Nothing to be done
  75.         Case -1
  76.             If FileExists($szFile) Then SetError(2)
  77.             ContinueCase
  78.         Case Else
  79.             $szContent = FileRead($szFile)
  80.             If @error And FileExists($szFile) Then Return SetError(3)
  81.             $f = FileOpen($szFile, 2 + 8 + 32) ; delete, create, utf-16 le
  82.             If $f = -1 Then Return SetError(4)
  83.             If FileWrite($f, $szContent) = 0 Then SetError(5, FileClose($f) * 0)
  84.             FileClose($f)
  85.  
  86.             Return 1
  87.     EndSwitch
  88. EndFunc   ;==>_IniConvertToUnicode
  89.  
  90. ;#Function# =====================================================================================================================
  91. ; Name............: _IniConvertToANSI
  92. ; Description.....: Converts encoding format of a text file to ANSI
  93. ; Syntax..........: _IniConvertToANSI($szFile, $fCreate = True)
  94. ; Parameters......:
  95. ;                   $szFile      - Path to text file (won't work with binary encoded files)
  96. ;                   $fCreate     - [optional]  The File will be created if it does not exist (default)
  97. ; Return values ..:
  98. ;                   Success      - Returns 1 - sets @extended = 1 if the file is already encoded correctly
  99. ;                   Failure      - Returns 0 - sets @error
  100. ;                                              | 1 - The file does not exist (requires $fCreate = False)
  101. ;                                              | 2 - The file is not a text file
  102. ;                                              | 3 - Reading the file failed
  103. ;                                              | 4 - Opening the file with ANSI failed
  104. ;                                              | 5 - Writing the file with ANSI failed
  105. ; Author .........: FichteFoll
  106. ; Modified........:
  107. ; Remarks ........: This is the oppsite of _IniConvertToUnicode. Characters that are Uincode-only will be converted to '?'.
  108. ; Related ........: FileGetEncoding, IniRead, IniWrite, IniReadSection, IniWriteSection, IniReadSectionNames
  109. ; Link ...........; See on top
  110. ; Example ........; _IniConvertToANSI("c:/file.ini")
  111. ; ===============================================================================================================================
  112. Func _IniConvertToANSI($szFile, $fCreate = True)
  113.     If Not FileExists($szFile) And $fCreate = False Then Return SetError(1)
  114.  
  115.     Local $iEncoding, $szContent, $f
  116.     $iEncoding = FileGetEncoding($szFile)
  117.  
  118.     Switch $iEncoding
  119.         Case 0
  120.             Return SetExtended(1, 1) ; Nothing to be done
  121.         Case -1
  122.             If FileExists($szFile) Then SetError(2)
  123.             ContinueCase
  124.         Case Else
  125.             $szContent = FileRead($szFile)
  126.             If @error And FileExists($szFile) Then Return SetError(3)
  127.             $f = FileOpen($szFile, 2 + 8 + 0) ; delete, create, ansi
  128.             If $f = -1 Then Return SetError(4)
  129.             If FileWrite($f, $szContent) = 0 Then SetError(5)
  130.             FileClose($f)
  131.  
  132.             Return 1
  133.     EndSwitch
  134. EndFunc   ;==>_IniConvertToANSI
  135.  
  136. ; ###############################################################################################################################
  137.  
  138. ;#Function# ============================================================================================================================================
  139. ; Name............: _IniReadToArray
  140. ; Description.....: Returns the whole ini file into one array with three dimensions
  141. ; Syntax..........: _IniReadToArray($szFile)
  142. ; Parameters......:
  143. ;                   $szFile      - Path to the ini file
  144. ; Return values ..:
  145. ;                   Success      - Returns an array containing all sections, keys and values (see Remarks)
  146. ;                   Failure      - Returns 0 and sets @error = 1 if the section names could not be determined
  147. ; Author .........: FichteFoll
  148. ; Modified........:
  149. ; Remarks ........: On success the array has the following structure:
  150. ;                      [0][0][0] = section count
  151. ;                      [n][0][0] = nth Section name
  152. ;                      [n][0][1] = nth Section's key count
  153. ;                      [n][m][0] = nth Section's mth key's name (just like IniReadSection)
  154. ;                      [n][m][1] = nth Section's mth key's value (just like IniReadSection)
  155. ;                   If some sections could not be allocated, its key count is set to 0 which also happens if there is no key in the section.
  156. ;                   Check @extended for the total count of sections that could not be read or have 0 keys inside.
  157. ; Related ........: _IniWriteFromArray, IniReadSectionNames, IniReadSection
  158. ; Link ...........; See on top
  159. ; Example ........; $aArray = _IniReadToArray("c:\file.ini")
  160. ;                   For $i = 1 To $aArray[0][0][0]
  161. ;                       ConsoleWrite(StringFormat("! [%s]", $aArray[$i][0][0]) & @CRLF)
  162. ;                       For $j = 1 To $aArray[$i][0][1]
  163. ;                           ConsoleWrite(StringFormat("- %s=%s", $aArray[$i][$j][0], $aArray[$i][$j][1]) & @CRLF)
  164. ;                       Next
  165. ;                   Next
  166. ; ======================================================================================================================================================
  167. Func _IniReadToArray($szFile)
  168.     Local $aszSections, $aReturn[1], $aszSection, $iMaxKeys = 1, $ext
  169.  
  170.     $aszSections = IniReadSectionNames($szFile)
  171.     If @error Then Return SetError(1)
  172.  
  173.     ReDim $aReturn[$aszSections[0] + 1][$iMaxKeys + 1][2]
  174.     $aReturn[0][0][0] = $aszSections[0]
  175.  
  176.     For $i = 1 To $aszSections[0]
  177.         $aReturn[$i][0][0] = $aszSections[$i]
  178.  
  179.         $aszSection = IniReadSection($szFile, $aszSections[$i])
  180.         If @error Then ; ususally no errors here, just go to next section in that case
  181.             $aReturn[$i][0][1] = 0
  182.             $ext += 1
  183.             ContinueLoop
  184.         EndIf
  185.  
  186.         $aReturn[$i][0][1] = $aszSection[0][0]
  187.         If $aszSection[0][0] > $iMaxKeys Then
  188.             $iMaxKeys = $aszSection[0][0]
  189.             ReDim $aReturn[$aszSections[0] + 1][$iMaxKeys + 1][2]
  190.         EndIf
  191.         For $j = 1 To $aszSection[0][0]
  192.             $aReturn[$i][$j][0] = $aszSection[$j][0]
  193.             $aReturn[$i][$j][1] = $aszSection[$j][1]
  194.         Next
  195.     Next
  196.  
  197.     Return SetExtended($ext, $aReturn)
  198. EndFunc   ;==>_IniReadToArray
  199.  
  200. ;#Function# =====================================================================================================================
  201. ; Name............: _IniWriteFromArray
  202. ; Description.....: Writes or creates an Ini out of an array
  203. ; Syntax..........: _IniWriteFromArray($szFile, Const ByRef $aArray, $fUnicode = False, $fDelete = True)
  204. ; Parameters......:
  205. ;                   $szFile      - Path to the ini file
  206. ;       Const ByRef $aArray      - The array containing the ini data; with three dimensions, 2 elements in the third and the following format:
  207. ;                                   [0][0][0|1] - not relevant, can contain values from _IniReadToArray
  208. ;                                  ![n][0][0] - nth section name
  209. ;                                   [n][0][1] - not relevant, can contain value from _IniReadToArray
  210. ;                                  ![n][m][0] - nth section's mth key name
  211. ;                                  ![n][m][1] - nth section's mth key value
  212. ;                   $fUnicode    - [optional] The ini will be encoded with Unicode using _IniConvertToUnicode
  213. ;                   $fDelete     - [optional] The whole file gets deleted before the array will be written into it;
  214. ;                                             sections will always be overwritten
  215. ; Return values ..:
  216. ;                   Success      - Returns 1
  217. ;                   Failure      - Returns 0 - sets @error
  218. ;                                              | 1 - Array is badly formatted
  219. ;                                              | 2 - Ini could not be converted to Unicode
  220. ;                                              | 3 - Every section has failed to be written
  221. ; Author .........: FichteFoll
  222. ; Remarks ........: This function is the opposite of _IniReadToArray and compatible with its return value.
  223. ;                   If a section fails to be written @extended is set to the total count of failures.
  224. ;                   If @extended is going to be the total count of sections @error is set to 3 and 0 returned.
  225. ; Related ........: _IniReadFromArray, IniWriteSection
  226. ; Link ...........; See on top
  227. ; Example ........; $aArray = _IniReadToArray("c:\file.ini")
  228. ;                   $aArray[1][1][1] = "the first value of this ini has changed"
  229. ;                   _IniWriteFromArray("c:\file2.ini", $aArray, True)
  230. ; ===============================================================================================================================
  231. Func _IniWriteFromArray($szFile, Const ByRef $aArray, $fUnicode = False, $fDelete = True)
  232.     If UBound($aArray, 0) <> 3 Or UBound($aArray, 3) <> 2 Then Return SetError(1) ; bad formatted
  233.     If $fDelete Then FileDelete($szFile)
  234.     If $fUnicode Then
  235.         _IniConvertToUnicode($szFile)
  236.         If @error Then Return SetError(2)
  237.     EndIf
  238.  
  239.     Local $ext = 0
  240.  
  241.     For $i = 1 To UBound($aArray, 1) - 1
  242.         Local $aszSection[1][2]
  243.  
  244.         For $j = 1 To UBound($aArray, 2) - 1
  245.             If $aArray[$i][$j][0] = "" And $aArray[$i][$j][1] = "" Then ExitLoop ; empty entry
  246.             ReDim $aszSection[$j+1][2]
  247.             $aszSection[$j][0] = $aArray[$i][$j][0]
  248.             $aszSection[$j][1] = $aArray[$i][$j][1]
  249.         Next
  250.  
  251.         IniWriteSection($szFile, $aArray[$i][0][0], $aszSection)
  252.         If @error Then $ext += 1
  253.     Next
  254.  
  255.     If $ext = UBound($aArray, 1) Then Return SetError(3)
  256.     Return SetExtended($ext, 1)
  257. EndFunc   ;==>_IniWriteFromArray
  258.  
  259. ; ###############################################################################################################################
  260.  
  261. ;#Function# =====================================================================================================================
  262. ; Name............: _IniReadFromString
  263. ; Description.....: Returns the value of a key in a specific section of an ini-formatted string
  264. ; Syntax..........: _IniReadFromString($szInput, $szSection, $szKey, $Default)
  265. ; Parameters......:
  266. ;                   $szInput     - The string that contains data in ini format
  267. ;                   $szSection   - The sectionname (just as in IniRead)
  268. ;                   $szKey       - The keyname (just as in IniRead)
  269. ;                   $Default     - The default value if the key does not exist or reading failed (just as in IniRead)
  270. ; Return values ..:
  271. ;                   Success      - Returns the read value
  272. ;                   Failure      - Returns $Default
  273. ; Author .........: FichteFoll
  274. ; Remarks ........: Works for Unicode as well as for ANSI
  275. ; Related ........: IniRead, _IniReadSectionFromString
  276. ; Link ...........; See on top
  277. ; Example ........; $var = _IniReadFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2"), "Sect", "MyKey2", "no_value")
  278. ; ===============================================================================================================================
  279. Func _IniReadFromString($szInput, $szSection, $szKey, $Default)
  280.     Local $szRegExpSection = "(?ix) (?<=\A)\s* \[ ([^\]]*)"
  281.     Local $szRegExpNamedSection = "(?ix) (?<=\A)\s* \[" & __StringEscapeRegExp($szSection)
  282.     Local $szRegExpNamedLine = "(?ix) (?<=\A)\s*(?!;) " & __StringEscapeRegExp($szKey) & " \s* = \s* (.*?) \s*(?=\Z)"
  283.  
  284.     $szInput = StringStripCR(StringRegExpReplace($szInput, "\r(?!\n)", "\r\n"))
  285.     Local $aszLines = StringSplit($szInput, @LF), $fFound = False, $aRegMl
  286.  
  287.     For $i = 1 To $aszLines[0]
  288.         If StringRegExp($aszLines[$i], $szRegExpNamedSection) Then
  289.             $fFound = True
  290.             ContinueLoop
  291.         ElseIf $fFound Then
  292.             If StringRegExp($aszLines[$i], $szRegExpSection) Then ExitLoop
  293.             $aRegMl = StringRegExp($aszLines[$i], $szRegExpNamedLine, 1)
  294.             If Not @error Then Return $aRegMl[0]
  295.         EndIf
  296.     Next
  297.  
  298.     Return SetError(1, 0, $Default) ; key not found
  299. EndFunc   ;==>_IniReadFromString
  300.  
  301. ;#Function# =====================================================================================================================
  302. ; Name............: _IniReadSectionNamesFromString
  303. ; Description.....: Returns all section names of an ini-formatted string
  304. ; Syntax..........: _IniReadSectionNamesFromString($szInput)
  305. ; Parameters......:
  306. ;                   $szInput     - The string that contains data in ini format
  307. ; Return values ..:
  308. ;                   Success      - Returns an array containing the section names; $result[0] contains the number of sections
  309. ;                   Failure      - Returns 0 and sets @error = 1 which means that no sections were found, this can have several reasons
  310. ; Author .........: FichteFoll
  311. ; Remarks ........: A section does not have to contain keys
  312. ; Related ........: IniReadSectionNames, IniReadSection
  313. ; Link ...........; See on top
  314. ; Example ........; $result = _IniReadSectionNamesFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2"), "Sect", "MyKey2", "no_value")
  315. ; ===============================================================================================================================
  316. Func _IniReadSectionNamesFromString($szInput)
  317.     Local $szRegExpSection = "(?ix) (?<=\n|\A)\s* \[ ([^\]]*)"
  318.     $szInput = StringStripCR($szInput)
  319.  
  320.     Local $aRegMl = StringRegExp($szInput, $szRegExpSection, 3)
  321.     If @error Then Return SetError(1) ; nothing found
  322.  
  323.     Local $iUBound = UBound($aRegMl), $aReturn[$iUBound + 1]
  324.     $aReturn[0] = $iUBound
  325.     For $i = 0 To $iUBound - 1
  326.         $aReturn[$i + 1] = $aRegMl[$i]
  327.     Next
  328.  
  329.     Return $aReturn
  330. EndFunc   ;==>_IniReadSectionNamesFromString
  331.  
  332. ;#Function# =====================================================================================================================
  333. ; Name............: _IniReadSectionFromString
  334. ; Description.....: Returns all keys and its values from a given section name of an ini-formatted string
  335. ; Syntax..........: _IniReadSectionFromString($szInput, $szSection)
  336. ; Parameters......:
  337. ;                   $szInput     - The string that contains data in ini format
  338. ;                   $szSection   - The section name
  339. ; Return values ..:
  340. ;                   Success      - Returns an array containing the data;
  341. ;                                  $result[0][0] will contain the number of sectins, [n][0] the key and [n][1] the value
  342. ;                   Failure      - Returns 0 and sets @error = 1 meaning that the section was not found
  343. ; Author .........: FichteFoll
  344. ; Remarks ........: [0][0] can be 0 if the section has no keys, the array will not have any more elements
  345. ; Related ........: IniReadSection, IniWriteSection
  346. ; Link ...........; See on top
  347. ; Example ........; $result = _IniReadSectionFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2"), "Sect")
  348. ; ===============================================================================================================================
  349. Func _IniReadSectionFromString($szInput, $szSection)
  350.     ; Using RegExp rarely does not work; using workaround by parsing the lines into an array instead
  351.  
  352.     Local $szRegExpSection = "(?ix) (?<=\A)\s* \[ ([^\]]*)"
  353.     Local $szRegExpNamedSection = "(?ix) (?<=\A)\s* \[" & __StringEscapeRegExp($szSection)
  354.     Local $szRegExpLine = "(?ix) (?<=\A)\s*(?!;) (.*?) \s* = \s* (.*?) \s*\Z"
  355.  
  356.     $szInput = StringStripCR(StringRegExpReplace($szInput, "\r(?!\n)", "\r\n"))
  357.     Local $aszLines = StringSplit($szInput, @LF), $aReturn[1][2] = [[0, 0]], $fFound = False, $aRegMl, $j = 0
  358.  
  359.     For $i = 1 To $aszLines[0]
  360.         If StringRegExp($aszLines[$i], $szRegExpNamedSection) Then
  361.             $fFound = True
  362.             ContinueLoop
  363.         ElseIf $fFound Then
  364.             If StringRegExp($aszLines[$i], $szRegExpSection) Then ExitLoop
  365.             $aRegMl = StringRegExp($aszLines[$i], $szRegExpLine, 1)
  366.             If @error Then ContinueLoop
  367.             $j += 1
  368.             $aReturn[0][0] = $j
  369.             ReDim $aReturn[$j + 1][2]
  370.             $aReturn[$j][0] = $aRegMl[0]
  371.             $aReturn[$j][1] = $aRegMl[1]
  372.         EndIf
  373.     Next
  374.     If $fFound = False Then Return SetError(1)
  375.     ; If $j = 0 Then Return SetError(2) ; return empty array instead
  376.  
  377.     Return $aReturn
  378. EndFunc   ;==>_IniReadSectionFromString
  379.  
  380. ;#Function# ============================================================================================================================================
  381. ; Name............: _IniReadToArrayFromString
  382. ; Description.....: Returns the whole ini file into one array with three dimensions
  383. ; Syntax..........: _IniReadToArrayFromString($szFile)
  384. ; Parameters......:
  385. ;                   $szInput      - The string that contains data in ini format
  386. ; Return values ..:
  387. ;                   Success      - Returns an array containing all sections, keys and values (see Remarks)
  388. ;                   Failure      - Returns 0 and sets @error = 1 if the section names could not be determined
  389. ; Author .........: FichteFoll
  390. ; Modified........:
  391. ; Remarks ........: On success the array has the following structure:
  392. ;                      [0][0][0] = section count
  393. ;                      [n][0][0] = nth Section name
  394. ;                      [n][0][1] = nth Section's key count
  395. ;                      [n][m][0] = nth Section's mth key's name (just like IniReadSection)
  396. ;                      [n][m][1] = nth Section's mth key's value (just like IniReadSection)
  397. ;                   If some sections could not be allocated, its key count is set to 0 which also happens if there is no key in the section.
  398. ;                   Check @extended for the total count of sections that could not be read or have 0 keys inside.
  399. ; Related ........: _IniReadToArray, _IniWriteToArray, _IniReadSectionNamesFromString, _IniReadSectionFromString
  400. ; Link ...........; See on top
  401. ; Example ........; $aArray = _IniReadToArrayFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2\r\n[Sect_2]\r\nYourKey1=value1"))
  402. ;                   For $i = 1 To $aArray[0][0][0]
  403. ;                       ConsoleWrite(StringFormat("! [%s]", $aArray[$i][0][0]) & @CRLF)
  404. ;                       For $j = 1 To $aArray[$i][0][1]
  405. ;                           ConsoleWrite(StringFormat("- %s=%s", $aArray[$i][$j][0], $aArray[$i][$j][1]) & @CRLF)
  406. ;                       Next
  407. ;                   Next
  408. ; ======================================================================================================================================================
  409. Func _IniReadToArrayFromString($szInput)
  410.     Local $aszSections, $aReturn[1], $aszSection, $iMaxKeys = 1, $ext
  411.  
  412.     $aszSections = _IniReadSectionNamesFromString($szInput)
  413.     If @error Then Return SetError(1)
  414.  
  415.     ReDim $aReturn[$aszSections[0] + 1][$iMaxKeys + 1][2]
  416.     $aReturn[0][0][0] = $aszSections[0]
  417.  
  418.     For $i = 1 To $aszSections[0]
  419.         $aReturn[$i][0][0] = $aszSections[$i]
  420.  
  421.         $aszSection = _IniReadSectionFromString($szInput, $aszSections[$i])
  422.         If @error Then ; ususally no errors here, just go to next section in that case
  423.             $aReturn[$i][0][1] = 0
  424.             $ext += 1
  425.             ContinueLoop
  426.         EndIf
  427.  
  428.         $aReturn[$i][0][1] = $aszSection[0][0]
  429.         If $aszSection[0][0] > $iMaxKeys Then
  430.             $iMaxKeys = $aszSection[0][0]
  431.             ReDim $aReturn[$aszSections[0] + 1][$iMaxKeys + 1][2]
  432.         EndIf
  433.         For $j = 1 To $aszSection[0][0]
  434.             $aReturn[$i][$j][0] = $aszSection[$j][0]
  435.             $aReturn[$i][$j][1] = $aszSection[$j][1]
  436.         Next
  437.     Next
  438.  
  439.     Return SetExtended($ext, $aReturn)
  440. EndFunc   ;==>_IniReadToArrayFromString
  441.  
  442. ; ###############################################################################################################################
  443.  
  444. ; ===============================================
  445. ; = Internal Use Only
  446. ; ===============================================
  447. Func __StringEscapeRegExp($szExp)
  448.     $szExp = StringRegExpReplace($szExp, "([\(\)\[\]\{\}\\\/\?\.\\|\+])", "\\$1") ; ()[]{}\/?.|+
  449.     Return StringRegExpReplace($szExp, "(\s)", "\\s")
  450. EndFunc   ;==>__StringEscapeRegExp
Advertisement
Add Comment
Please, Sign In to add comment