Jump to content
Sign in to follow this  
gcue

alphabetize ini section values

Recommended Posts

gcue

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

[section_name]

Frank=232323

Albert=34342323

Zeek=23232323

Barbara=231212

any ideas?

Share this post


Link to post
Share on other sites
oMBRa

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
gcue

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.

Share this post


Link to post
Share on other sites
oMBRa

lol I didnt know _arraysort that's easier xD

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
gcue

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
gcue

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. =/

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
gcue

lol!

;)

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

Share this post


Link to post
Share on other sites
weaponx

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".

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
gcue

hahhaha ok u guys are killing me!!!

Share this post


Link to post
Share on other sites
JFee
;) 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

Share this post


Link to post
Share on other sites
YellowLab

@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.

Share this post


Link to post
Share on other sites
gcue

my ini entries are displayed as icons.. i want to alphabetize just for easy readability reasons

Share this post


Link to post
Share on other sites
JFee

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

Share this post


Link to post
Share on other sites
gcue

ok i think i know why theres an error.. the array display has two columns not just one...

any ideas??

Share this post


Link to post
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
Sign in to follow this  

×