Sign in to follow this  
Followers 0
qazwsx

Guictrlsetdata problem

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

yeh thats is what i was thinking, but doenst the guictrlsetdata have to be done at once?

Share this post


Link to post
Share on other sites

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´6­kl=ªÚë^­«­¢+Ù1½°ÀÌØíÑôÅÕ½ÐìÅÕ½Ðì)½ÈÀÌØí¤ôÀQ¼U  ½Õ¹ ÀÌØíÉÉ䤴Äí½È ÉÉ丸(U%
ÑɱMÑÑ ÀÌØí1¥ÍÑ
½¹Ñɽ°°ÀÌØíÉÉålÀÌØí¥t°Ä¤íUÍ¥¹Ñ¡ÄÁɵÑȱ±½ÝÌÕÌѼ­ÀÑ¡½É¥¥¹°Ñ)9áÐ

Once again, all untested, but should work :)

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

And funnily enough there's a function IniReadSectionNames() which returns an array of section names.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

thx man the second one worked.

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  
Followers 0