qazwsx Posted September 4, 2007 Posted September 4, 2007 I am trying to set the data for a list control. The data i want to use is the section names of an ini file. I was thinking arrays would be the best way to do this, but since i do not know how many items there may it gives me an error. Its more of a logic question than a coding one.
_Kurt Posted September 4, 2007 Posted September 4, 2007 Using For...Next Loops with arrays is very easy to work with, for example:Say there was a file with several lines, and for each line (aka for each @CR), I want it to display the line in the file through a msgbox but I don't know how many lines there are in the file.$file = FileRead("test.txt") $split = StringSplit($file, @CR) ;Create an array for each line For $i = 1 To UBound($split)-1 Msgbox(0,"Line #" & $i, $split[$i]) Next ;Done(Untested, wrote it off the top of my head)Hope the example can give you an idea of what you want to do.Kurt Awaiting Diablo III..
qazwsx Posted September 4, 2007 Author Posted September 4, 2007 yeh thats is what i was thinking, but doenst the guictrlsetdata have to be done at once?
_Kurt Posted September 4, 2007 Posted September 4, 2007 There are two ways to approach this, #1: Storing each array value in a string Local $data = "" For $i = 0 To UBound($array)-1 ;For each array.. $data &= $array[$i] & "|" ;the $data string will hold each array value, each seperated with a "|" Next $data = StringTrimRight($data, 1) ;Trim the extra "|" added in the For..Next Loop GUICtrlSetData($ListControl, $data)oÝ÷ Ûe,xP®T´6kl=ªÚë^«¢+Ù1½°ÀÌØíÑôÅÕ½ÐìÅÕ½Ðì)½ÈÀÌØí¤ôÀQ¼U ½Õ¹ ÀÌØíÉÉ䤴Äí½È ÉÉ丸(U% ÑɱMÑÑ ÀÌØí1¥ÍÑ ½¹Ñɽ°°ÀÌØíÉÉålÀÌØí¥t°Ä¤íUÍ¥¹Ñ¡ÄÁɵÑȱ±½ÝÌÕÌѼÀÑ¡½É¥¥¹°Ñ)9áÐ Once again, all untested, but should work Kurt Awaiting Diablo III..
Siao Posted September 4, 2007 Posted September 4, 2007 And funnily enough there's a function IniReadSectionNames() which returns an array of section names. "be smart, drink your wine"
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