Jump to content
Sign in to follow this  
Gnat

GUICtrlRead issue

Recommended Posts

Gnat

I am working on a script that requires a lot of input from the end-user, and then takes all of that input and stores it in an .ini file. When creating the GUICtrlCreateInputs, I assign them to a variable (ex. $var1=GUICtrlCreateInput("text", X, Y) ) and then when I try to have all of that saved to the .ini file, I use a While loop to count up the $varX variable and using a GUICtrlRead($control), but I don't get the data for the control, all I get is a bunch of zeros. I think it all has to do with the way that I am doing a count to create the controlID, but I am not sure. Can someone please help :whistle: ....(see code snippet below)...

...

$c1001 = GUICtrlCreateInput("", 100, 200)

$c1002 = GUICtrlCreateInput("", 100, 225)

etc...

...

$iniFile = FileOpen(@SystemDir & "\" & $name & ".ini", 2)

$counter = 1001

While $counter < 1035

$control = "$c" & $counter

FileWriteLine($iniFile, GUICtrlRead($control))

$counter = $counter + 1

Wend

If I put in a message box to check the value of the control's variable from the loop, I get the right output for the controlID's assigned variable.

...

$c1001 = GUICtrlCreateInput("", 100, 200)

$c1002 = GUICtrlCreateInput("", 100, 225)

etc...

...

$iniFile = FileOpen(@SystemDir & "\" & $name & ".ini", 2)

$counter = 1001

While $counter < 1035

$control = "$c" & $counter

MsgBox(0, "Heading", $control)

FileWriteLine($iniFile, GUICtrlRead($control))

$counter = $counter + 1

Wend

Thanx in advance...

Share this post


Link to post
Share on other sites
Gnat

Try using Eval:

...
$counter = 1001
While $counter < 1035
$control = Eval("c" & $counter) <-
MsgBox(0, "Heading", $control)
FileWriteLine($iniFile, GUICtrlRead($control))
...

Regards

Holger

<{POST_SNAPBACK}>

That gives me the actual controlID number and unfortunately does not fulfill my requirements. Thanx anyway.

Share this post


Link to post
Share on other sites
wfuehrer

Hi!

You should use an array ( $c[1] ) instead of vars ( $c1001 ). This should work.

I used that for my dynamically growing gui. So my gui can handle systems from 1 to ~20 partitions (then the screen size will be to small ). ;)


Wolfgang F├╝hrer

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.