schmidt2 Posted March 13, 2007 Posted March 13, 2007 hello guys, i am a newbie who got stuck with maybe an very easy thing.(?) i've got an ini file and need to get 2 groups of section names put into two different arrays. example: [a_something_else] ... [section_1] ... [section_2] ... [another_something_else] .. [extension_1] ... [extension_2] ... first i got all the section titles with "IniReadSectionNames". as the wanted names are "section_x" and "extension_x" i used an "_ArraySort" and "_ArrayDelete" to get rid of the [a_something_else] and [another_something_else] section names. ! this works in my special case as those always start with an "a" (they are on top of the array after sorting it) and i know how much of them are in the ini file (so even an _ArrayDelete works here). but now i do not get the point how to split the remaining array into two ones, as the number of the section names [section_x] and [extension_x] varies every time: array_1[0]=extension_1 array_1[1]=extension_2 array_1[x]=extension_x array_1[x+1]=section_1 array_1[x+2]=section_2 array_1[x+x]=section_x that is how my array looks like know but i need something like this: ;first array array_1[0]=extension_1 array_1[1]=extension_2 array_1[x]=extension_x ;and second one array_2[1]=section_1 array_2[2]=section_2 array_2[x]=section_x i'm sure there is an easy solution and it's only me, the newbie not to see the wood for the trees? :"> thanks in advance for your help
SadBunny Posted March 13, 2007 Posted March 13, 2007 To me the easiest solution seems to get the total number of sections, for instance by UBound (after you got rid of the junk ofcourse), divide it by two, and doing two for-loops to read them in. If you want them in two different array names that is. You might also want to consider double-dimensioned arrays, like Dim $array[x][2] (two elements for every x). Roses are FF0000, violets are 0000FF... All my base are belong to you.
schmidt2 Posted March 13, 2007 Author Posted March 13, 2007 thanks for your fast reply but i should mention that the amount of the [extension_x] and [section_x] section names aren't always equal. for example there might be 2 "extension" ones and 10 with the "section" section name.
schmidt2 Posted March 14, 2007 Author Posted March 14, 2007 (edited) Got it after i hit the hay, and it was really easy. :"> Maybe there are some other newbies around who will come up with the same question so here is my solution how i solved my problem: IniReadSectionNames () ; getting all the section names _ArraySort () ; you do not really need this (but both new arrays you'll get below are than already sorted) _ArrayToString () ; putting the array into an string (as i found no option to do an RegExp search in arrays) StringRegExp () ; searching for "section_x" and putting it into an array StringRegExp () ; searching for "extension_x" and putting it into an array Voila, there are to new arrays each containing either all "section_x" or all "extension_x" names. Edited March 14, 2007 by schmidt2
Hillbilly Posted March 14, 2007 Posted March 14, 2007 Got it after i hit the hay, and it was really easy. :"> Maybe there are some other newbies around who will come up with the same question so here is my solution how i solved my problem: IniReadSectionNames () ; getting all the section names _ArrayToString () ; putting the array into an string (as i found no option to do an RegExp search in arrays) :"> Look for _StringBetween in the UDFs3 help file. You'll find a switch $iSRE refering to regular expression search of an array.
schmidt2 Posted March 15, 2007 Author Posted March 15, 2007 Thanks for your tip. :"> Look for _StringBetween in the UDFs3 help file.You'll find a switch $iSRE refering to regular expression search of an array.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now