Sign in to follow this  
Followers 0
saywell

GUI Control update using a loop [solved]

3 posts in this topic

#1 ·  Posted (edited)

I'm writing a GUI that will allow users to configure the ini file of my main app.

I'm stumbling at the first hurdle!

The items I'm working with are for a combo box on the main prog's gui - so there's a default entry and subsequent entries, the latter read in from the ini file and separated by pipes.

I'm splitting these by pipe into an array, then need to write them to sequentially-numbered input boxes n the config GUI, as a start point for modification by the user. they will then be read back in.

The input boxes are in a tab [if that makes any difference] and are $input025 to $$input062 [though probably only 6-12 will actually be used by most users]. $input 024 s the Default Header

So far I have written this:

Func Load()

#region ; headers
$sDefHead = "Default Header"
$sOtherHeads = "Second Header|Third Header|Fourth Header|Fifth Header" ;these 2 lines just for forum post, rather thn earlier read-in from ini file

GUICtrlSetData ($input024, $sDefHead)
$aHeads = StringSplit ($sOtherHeads, "|")    ; zero-based array of other headers
;_ArrayDisplay ($aHeads)

$a = 1
for $i = 25 to 62
    Local $sHeadNo = "0" & String ($i)
    Local $sInputNo = "$input" & $sHeadNo
    MsgBox (4096,"$sInputNo, $aHeads[$a]", $sInputNo &@CR&$aHeads[$a])
    GUICtrlSetData ($sInputNo,$aHeads[$a])


    $a = $a + 1
    if $a = $aHeads[0] Then ExitLoop  ; exits loop when upper limit of array is readed - ie all entries from ini file have loaded
Next
#endregion ; - Headers


GUISetState(@SW_SHOW)
EndFunc   ;=====> Load

The default header writes to the GUI, but the others don't, though the words in the message box look right. It's the first time I've tried 'automating' variable names, so I've probably got something fundamentally wrong here!

If the code isn't enough to show the error, I'll come back later with a cut-down version of the GUI as a sandbox.

Any suggestions as to how best to do it would be welcomed!

Regards,

William

Edited by saywell

Share this post


Link to post
Share on other sites



Maybe that a more complete example might help.

If I'm correct you are trying to set the content of some input fields within the loop and with data from the array.

I don't think this will work without a window on which these input fields are created.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks.

Having ferretted around the help etc I've come up with the solution.

adding:

Local $sInputNo = Eval("input" & $sHeadNo)

as the second line in the loop. Temporarily flummoxed by the non-requirement for the $ in the first term, but got there in the end!

William

Edited by saywell

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