Jump to content

alphabetize ini section values


gcue
 Share

Recommended Posts

MATH IS THE KEY!

u can associate each letter of the alphabet with a number like: a = 1 b = 2 then compare them with the first letter of each values name and write it in order

Edited by oMBra
Link to comment
Share on other sites

how would you go about alphabetizing the values under a given section:

[section_name]

Frank=232323

Albert=34342323

Zeek=23232323

Barbara=231212

any ideas?

IniReadSection()

_ArraySort()

IniWriteSection()

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

great idea psalty!

not sure why i get an array error though:

"an array variable has incorrect number of subscripts or subscript dimension range exceeded."

$a = IniReadSection("assets.ini", "section_name")

_ArraySort($a)
_ArrayDisplay($a)

IniWriteSection("test.ini", "section_name", $a)

if i comment out the _arraysort($a) i dont get the error.

Link to comment
Share on other sites

great idea psalty!

not sure why i get an array error though:

"an array variable has incorrect number of subscripts or subscript dimension range exceeded."

$a = IniReadSection("assets.ini", "section_name")

_ArraySort($a)
_ArrayDisplay($a)

IniWriteSection("test.ini", "section_name", $a)

if i comment out the _arraysort($a) i dont get the error.

The count is in $a[0][0], and you don't want that sorted in with the rest. Use _ArraySort($a, 0, 1) instead (see the help file). Also, make sure you are running the current version.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

yep i had also checked the help file and tried 0,1 but i still get the error:

heres what the arraydisplay looks like (wout the sort):

Row Col 0 Col1

[0] 4

[1] Frank 232323

[2] Albert 232323

[3] Zeek 22332323

[4] Barbara 23232323

Link to comment
Share on other sites

yep i had also checked the help file and tried 0,1 but i still get the error:

heres what the arraydisplay looks like (wout the sort):

Row Col 0 Col1

[0] 4

[1] Frank 232323

[2] Albert 232323

[3] Zeek 22332323

[4] Barbara 23232323

This works fine:
#Include <Array.au3>

Global $avArray[5][2] = [[4, ""], ["Frank", 232323], ["Albert", 232323], _
    ["Zeek", 22332323], ["Barbara", 23232323]]
_ArraySort($avArray, 0, 1)
_ArrayDisplay($avArray)

What version of AutoIt are you running?

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

the example you posted didnt work for me either =/

im using 3.2.10

i need to use this version bc this is part of a ~8000 line script

and theres too many things to fix if i upgrade the complier. =/

Link to comment
Share on other sites

the example you posted didnt work for me either =/

im using 3.2.10

i need to use this version bc this is part of a ~8000 line script

and theres too many things to fix if i upgrade the complier. =/

I think you've said that before... and that excuse is only going to get more lame as time goes on...

;)

("8000 lines" = "Too big to maintain") = False

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I think you've said that before... and that excuse is only going to get more lame as time goes on...

;)

("8000 lines" = "Too big to maintain") = False

:D

He probably doesn't upgrade to digital cable because "its too many channels to maintain".

Link to comment
Share on other sites

lol!

:D

well actually i dont think anything else will get added to this script.. its definitely coming to a close. so id liek to just get this last change working on 3.2.10

You could try updating just that function in your Array.au3 UDF file.

Can't help you get service for that dial phone, though.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

;) Thanks for this idea... I've been meaning to alphabetize the entire ini by sections. I think I'll just IniReadSectionNames then loop through each one adding it to a variable containing all of the new alphabetized INI, then I'll have to FileWrite it. Does that sound about right?

Regards,Josh

Link to comment
Share on other sites

@JFee, sounds right.

However, I am a little confused why you would necessarily need an ini file alphabetized. You can alphabetize the entries for lists at the time they are needed to be displayed or compared. Just curious why you want to add the write time to make the internal aspects of a file look pretty? Also, if the ini files get large, it may be faster to use an SQLite database for storing these values. Alphabetizing the database is much faster.

Bob

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

Thanks for the reply. I have a ComboBox withe the style $CBS_SORT, and i have a bunch of information derived by a number of INI files. Nothing is broken right now, however it calls a function and loads information associated with the first INI section.

Regards,Josh

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...