Jump to content

How to concatenate two variables ?


Guest zitto
 Share

Recommended Posts

Hello,

I'm facing a little problem, hope you can help me. o:)

In my script, I have 60 radio buttons corresponding to 60 customers.

I have an array containing names of customers.

I want to test with a For condition which radio button is selected and then display the name of the customer, I mean if $radio0 is checked, display the value of $Array[0]

Problem is that here under I don't succeed to read the value of $radio"i" assuming i is a variable going from 0 to 59.

I don't succeed to make $radio"1" becoming the radio control $radio1

Can you help me ? Do you see what I mean ? :lmao:

Example : syntax of bold characters is false, I can't find how I can do that

Dim $1

Dim $radio

Dim $Array[60]

$radio0 = GUICtrlCreateRadio ("XXX", 10, 10, 50, 20)

$radio1 = GUICtrlCreateRadio ("YYY", 10, 30, 50, 20)

$radio2 = GUICtrlCreateRadio ("ZZZ", 10, 50, 50, 20)

[...]

$Array[0] = "XXX"

$Array[1] = "YYY"

$Array[2] = "ZZZ"

[...]

$Button= GUICtrlCreateButton ( "Button", 70, 360 ,70, 20)

Do

$msg = GUIGetMsg()

For $i = 0 to 59

If GUICtrlRead("$radio" & $i) = $GUI_CHECKED Then

$Customer = $Array[$i]

EndIf

Next

if $msg = $Button Then

msgbox(0,"test", $Customer)

EndIf

Until $msg = $GUI_EVENT_CLOSE

Edited by zitto
Link to comment
Share on other sites

  • Administrators

Put your control ids in a similar array:

Dim $Radio[60]

$Radio[0] = GUICtrlCreateRadio ("XXX", 10, 10, 50, 20)
$Radio[1] = GUICtrlCreateRadio ("YYY", 10, 30, 50, 20)

Then when you loop through Radio[0] to Radio[59] and find one that is selected you automatically know which customer it corresponds to.

Link to comment
Share on other sites

Or use a 2 dimensional array...

Dim $aRadios[60][2]
; Populate array somehow
$aRadios[0][0] = "XXX"
$aRadios[0][1] = "YYY"
...

; Write an algorithm to place controls at intervals
Local $x = 10, $y = 10
For $i = 0 To UBound($aRadios)-1
    $aRadios[$i][1] = GUICtrlCreateRadio($aRadios[$i][0], $x, $y+($i*20), 50, 20)
Next

That would create all 60 radio's in a top to bottom fashion. If you wanted multiple columns, then it would require more work, but is still a lot less code than doing it all by hand.

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