Sign in to follow this  
Followers 0
MrEd

Dynamically Create Radio Button Groups

8 posts in this topic

I am trying to create a form for selecting which VPN to use. The number of VPN's and their addresses fluctuates on a irregular basis. So I figured I could just create a 'picker' on the fly. I tried to create a test form with 10 buttons displayed in 2 columns of 5. I believe the logic is correct but the syntax is off.

Local $member = 1
Local $left = 24
Local $height = 25
Local $width = 128
Local $top = 64

$Form1 = GUICreate("VPN Mega Tool", 431, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Available VPN's", 8, 16, 297, 401)
While $member <= 10
    ; GUICtrlCreateRadio("text",left,top[,width[,height[,style[,exStyle]]]])
    ; two columns top of both 40, width of both 128, left column at 24, right column at 160
    ; top to top line is 24
    $radio & $member = GUICtrlCreateRadio("Button " & $member,$left,$top,$width,$height)
    $top = $top + 24
    $member = $member + 1
    If($member == 5) Then
        $left = 160
        $top = 64
    EndIf
WEnd
GUICtrlCreateGroup("", -99, -99, 1, 1)

It throws an error at the $radio & $member line. I think it is interpreting this as NUL1 instead of $Radio1

Any pointers?

Ed

Share this post


Link to post
Share on other sites



Could you please post the error message you get?

And can you please post a working reproducer script? That makes testing much easier for us!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You need to store the ControlDs in an array. Something like this:

#include <GUIConstantsEx.au3>
Global $member = 0
Global $left = 24
Global $height = 25
Global $width = 128
Global $top = 64

$Form1 = GUICreate("VPN Mega Tool", 431, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Available VPN's", 8, 16, 297, 401)
Global $Radio[10]
While $member < 10
    ; GUICtrlCreateRadio("text",left,top[,width[,height[,style[,exStyle]]]])
    ; two columns top of both 40, width of both 128, left column at 24, right column at 160
    ; top to top line is 24
    $radio[$member] = GUICtrlCreateRadio("Button " & $member + 1, $left, $top, $width, $height)
    $top = $top + 24
    $member = $member + 1
    If ($member == 5) Then
        $left = 160
        $top = 64
    EndIf
WEnd
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW) ; will display an empty dialog box
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Could you please post the error message you get?

And can you please post a working reproducer script? That makes testing much easier for us!

Exact error

>Running AU3Check (1.54.22.0)  from:C:\Program Files (x86)\AutoIt3
C:\Users\Ed\Documents\AutoITscripts\selectVPNtoOpen.au3(24,9) : ERROR: syntax error

It is the exact code the only thing lacking is the gui includes.

Share this post


Link to post
Share on other sites

Does the code I posted in #3 do what you need?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Another option you can use to join two variables, is Assign or Eval.

I always forget which it is, and I can't check at the moment, but one of those does the trick.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Yes! Thanks a million! This is my first GUI in AutoIt. Normally I just write dialog automation stuff, this is a whole new world. I tried the AutoIT 1-2-3 tutorial but it wanted the beta. I am not far enough in the curve to be playing with beta releases.

I have marked it as solved and I have to check my settings, I thought I had email notifications turned on.

Thanks again!

Ed

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