Jump to content

Guictrlsetdata problem


qazwsx
 Share

Recommended Posts

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.

Link to comment
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..

Link to comment
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..

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