Sign in to follow this  
Followers 0
EliTe_ThuT

Help me with a part of my script

5 posts in this topic

#1 ·  Posted (edited)

[GUI]

Hi, in my script I want that when I click on a button, it checks if one or more of the three check boxes are checked. If it's checked, I writes information in an Ini file, if not, well it doesn't do anything. But I'm not able to make an If ... then ... that checks for the three if...then... It only works for the first if ... then...

Not the 2 others...here's my code.

Case $msg = $Button_1
                
;Update Info
            $Checkbox1 = GUICtrlRead($Checkbox_1)
            $Checkbox2 = GUICtrlRead($Checkbox_2)
            $Checkbox3 = GUICtrlRead($Checkbox_3)
            
            $Input1 = GUICtrlRead($Input_1)
            $Input3 = GUICtrlRead($Input_3)
            $Input2 = GUICtrlRead($Input_2)
            
;Check for the "Remember"
            if $Checkbox1 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input1", $Input1)
            if $Checkbox2 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input2", $Input2)
            if $Checkbox2 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input3", $Input3)

Someone can help me with that plz?

EDIT: Sorry, I just realized this is supposed to be in the General Help and Support (GUI)...you can move my topic. Still need help though :whistle:

Edited by EliTe_ThuT

Share this post


Link to post
Share on other sites



;Check for the "Remember"
            if GuiCtrlRead($Checkbox1) = $GUI_CHECKED then 
                IniWrite("JTR.ini","Remember","Input1", $Input1)
            endif
            if GuiCtrlRead($Checkbox2) = $GUI_CHECKED then 
                IniWrite("JTR.ini","Remember","Input2", $Input2)
            endif
            if GuiCtrlRead($Checkbox3) = $GUI_CHECKED then 
                IniWrite("JTR.ini","Remember","Input3", $Input3)
            endif

You need to put an "EndIf" after every "If" used. I don't know why the script allowed execution but this should work.


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

#3 ·  Posted (edited)

"If condition then function()" doesn't require an EndIf.

Edit -

To answer the question, I think what you want to be doing is...

If condition Then

...

ElseIf condition Then

...

ElseIf condition Then

...

EndIf

...but I don't think i quite understood the question.

Edited by xcal

Share this post


Link to post
Share on other sites

You need to put an "EndIf" after every "If" used. I don't know why the script allowed execution but this should work.

Actually, I just found my mistake...and this is not my mistake.

When you put If ... Then ... on one line, you don't need EndIf. My problem was pretty simple.

if $Checkbox1 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input1", $Input1)
            if $Checkbox2 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input2", $Input2)
            if $Checkbox2 = $GUI_CHECKED then IniWrite("JTR.ini","Remember","Input3", $Input3)

I have if $Checkbox2 two times...that's why Checkbox 3 wasn't working...lol

Share this post


Link to post
Share on other sites

"If condition then function()" doesn't require an EndIf.

Thanks for the tip :)

I'm an "old school" boy and I prefer to do it properly each time.

Indeed the code is more complicated but at least I don't make mistakes.

But ... everyone has a style :whistle:


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

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