Jump to content
Sign in to follow this  
peanutym

Checkboxes is checked then do this help.

Recommended Posts

peanutym

The script below allows you to check up to 8 check boxes. What i would like the script to do it check and see if the checkbox is checked and then do whatever. But i need it to do that for all of the check boxes. Like if 1 4 5 are checked then it will go to the code for 1 4 5 to do whatever it says there.

I figured out the is checked code, but not sure of how to make it do the code in every box that is checked instead of just the first one it finds. Using something like

IF Bitand(GUIctrlread($function1), $GUI_CHECKED) then 
do stuff
else
check $function2

doesnt work because if the first box is checked it will never find out if multiples are checked. Any help is appreicated to get the logic correct so that it will check all 8 then do whatever is coded for each one.

#include <NomadMemory.au3>
#include <guiconstants.au3>
#include <GuiListView.au3>

;==============GUI=====================

$GUI_1=GuiCreate("", 350,200, -1, -1)
GUISetBkColor(0xc4ac64,$GUI_1)

$GUI_1=GUICtrlCreateGroup("Function Keys", 10, 10, 330, 100)
GUICtrlCreateLabel("Please check boxes that match the function keys that will be used.", 20, 30, 110, 50)

$function1 = GUICtrlCreateCheckbox("F1", 140,30,30,20)
$function2 = GUICtrlCreateCheckbox("F2", 180,30,30,20)
$function3 = GUICtrlCreateCheckbox("F3", 220,30,30,20)
$function4 = GUICtrlCreateCheckbox("F4", 260,30,30,20)
$function5 = GUICtrlCreateCheckbox("F5", 140,50,30,20)
$function6 = GUICtrlCreateCheckbox("F6", 180,50,30,20)
$function7 = GUICtrlCreateCheckbox("F7", 220,50,30,20)
$function8 = GUICtrlCreateCheckbox("F8", 260,50,30,20)

$start = GUICtrlCreateButton("Start", 120, 130, 100, 50)
GUISetState(@SW_SHOW)

Func start()

    If BitAND(GUICtrlRead($function1), $GUI_CHECKED) Then
    MsgBox (0, "Function 1", "F1 is checked", 1000)
Else
    If BitAND(GUICtrlRead($function2), $GUI_CHECKED) Then
        MsgBox (0, "Function 2", "F2 is checked", 1000)

    EndIf
    EndIf
    EndFunc

Func quit()
    Exit
EndFunc

;Leave open till i close you.
While 1
     $msg = GUIGetMsg()
     Select
        Case $msg = $GUI_Event_Close
            quit()
        Case $msg = $start
            start()

    EndSelect
WEnd

Share this post


Link to post
Share on other sites
enaiman

Here is what you can do: Build an 8 digit long string, 1st digit will be the state of the 1st checkbox (1=checked, 0=unchecked), 2nd for 2nd checkbox ... and so on.

Check all the boxes and build the result string according to their state.

Depending on the structure of the resulting string (or you can use the string as a binary number), use a Select or Switch statement to take appropriate action.

Warning: the number of resulting combinations might be quite long (256 possible combinations). It would be easier for you to consider only the cases you're interested in.

Good luck,

Note: It would be much easier for you to have the checkbox handles as array elements ($function[1], $function[2] ...)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
peanutym

ahh yea array would work nicely i think. ill try that first thanks!

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  

×