Jump to content

[SOLVED] IniReadSectionNames Sort


rootx
 Share

Recommended Posts

HI friends, I would order this array, starting from the name of the last folder.

My situation...

My file ini

[C:\program\room\p\file.exe]

[E:\program\room\a\file.exe]

[D:\program\room\m\file.exe]

Goal.... sort by last folder!  a-m-p

 Any Idea, THX

$ini = @ScriptDir&"\ini.ini"
$aArrays = IniReadSectionNames($ini)

For $i = 1 To UBound($aArrays)-1

    ConsoleWrite($aArrays[$i]&@CRLF)
    ConsoleWrite(StringRegExp($aArrays[$i],'.*\\(.*)\\',1)[0]&@CRLF)

Next

 

Edited by rootx
Link to comment
Share on other sites

Însert a Col and assign the wanted data to the new elements. After sort the array

#include <Array.au3>

$ini = @ScriptDir&"\ini.ini"
$aArrays = IniReadSectionNames($ini)
_ArrayColInsert($aArrays,1)

For $i = 1 To UBound($aArrays)-1
    $aArrays[$i][1]=StringRegExp($aArrays[$i][0],'.*\\(.*)\\',1)[0]
Next
_ArraySort($aArrays,0,1,0,1)
;_ArrayColDelete($aArrays,1)
_ArrayDisplay($aArrays)

If inserted col isn't needed you can delete it

 

Link to comment
Share on other sites

THX very good solution, I always do it in sql!! Fridayyyyyyy :hyper:

to complete.....

#include <Array.au3>

$ini = @ScriptDir&"\ini.ini"
$aArrays = IniReadSectionNames($ini)
_ArrayColInsert($aArrays,1)

For $i = 1 To UBound($aArrays)-1
    $aArrays[$i][1]=StringRegExp($aArrays[$i][0],'.*\\(.*)\\',1)[0]
Next
_ArraySort($aArrays,0,1,0,1)
_ArrayColDelete($aArrays,1,true);<------------------
_ArrayDisplay($aArrays)

 

Edited by rootx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...