Jump to content
Sign in to follow this  
AdmiralAlkex

how to have two expressions after an If

Recommended Posts

AdmiralAlkex

This is a copy of a part of my script, i have tried a few ways but i cant get the first one to execute, it is always the second one that is executed...... I cant find any useful info in the help-file..... plz give me some advice

...
ElseIf $frga17 = 1 And $frga10= 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "1")
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
    Exit
ElseIf $frga17 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
    Exit
...

Share this post


Link to post
Share on other sites
Paulie

Perhaps the variable called "$frga10" is not = 1.

In reality, there is no way to tell without more of the script.

Because this works for me:

$frga10=1
$frga17=1

If $frga17 = 1 And $frga10= 1 Then
    MsgBox(0,"Test", "1st condition.")
    Exit
ElseIf $frga17 = 1 Then
    MsgBox(0,"Test", "2nd condition.")
    Exit
EndIf
(Only the first condition appears) Edited by Paulie

Share this post


Link to post
Share on other sites
Generator

This is a copy of a part of my script, i have tried a few ways but i cant get the first one to execute, it is always the second one that is executed...... I cant find any useful info in the help-file..... plz give me some advice

...
ElseIf $frga17 = 1 And $frga10= 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "1")
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
    Exit
ElseIf $frga17 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
    Exit
...
oÝ÷ Ûú®¢×¯+aÆ®¶­s`¢ââà¤VÇ6Tbb33c¶g&vrÒæBb33c¶g&vÒFVà æw&FR67&DF"fײgV÷C²b3#²gV÷C²fײgV÷C¶F÷66öÖÖæG6ÖVçW6WGFæw2æægV÷C²ÂgV÷Cµ&Vv7G'6WGFæw2gV÷C²ÂgV÷Cµ6WGFærrgV÷C²ÂgV÷C³gV÷C² æw&FR67&DF"fײgV÷C²b3#²gV÷C²fײgV÷C¶F÷66öÖÖæG6ÖVçW6WGFæw2æægV÷C²ÂgV÷Cµ&Vv7G'6WGFæw2gV÷C²ÂgV÷Cµ6WGFær2gV÷C²ÂgV÷C³gV÷C² W@¤VÇ6Tbb33c¶g&vrÒæBb33c¶g&vfÇC²fwC³FVà æw&FR67&DF"fײgV÷C²b3#²gV÷C²fײgV÷C¶F÷66öÖÖæG6ÖVçW6WGFæw2æægV÷C²ÂgV÷Cµ&Vv7G'6WGFæw2gV÷C²ÂgV÷Cµ6WGFær2gV÷C²ÂgV÷C³gV÷C² W@¢ââà

Share this post


Link to post
Share on other sites
AdmiralAlkex

Ehhhm ok I am officially stupid....... It actually doesn't work at all so i am posting all my code

This app is supposed to read a few lines from an ini-file that another app create and then dependind on if you have the checkbox on or off and which button you press it should write new lines in the same ini-file so the other app can "do its work"

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$frga8 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 2", "0")
$frga11 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 4", "0")
$frga12 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 5", "0")
$frga13 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 6", "0")
$frga14 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "0")
$frga15 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 8", "0")
$frga16 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 9", "0")
$frga17 = IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 10", "0")

If $frga11 = 1 & $frga8 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
Exit
EndIf

If $frga13 = 1 & $frga8 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
Exit
EndIf

If $frga12 = 1 & $frga15 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
Exit
EndIf

If $frga14 = 1 & $frga15 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
Exit
EndIf

$frga1 = GUICreate("Fråga...", 400, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()
$frga2 = GuiCtrlCreateEdit("Att ändra något här innebär att registret ändras vilket kan vara farligt om något skulle bli fel.", 10, 10, 380, 75, BitOR($ES_MULTILINE, $ES_READONLY), $WS_EX_STATICEDGE)
GUICtrlSetFont (-1, 16)
$frga3 = GUICtrlCreateLabel("Är du säker på att du vill fortsätta??", 35, 95, 350, 25)
GUICtrlSetFont (-1, 16)
$frga4 = GUICtrlCreateButton("JA", 15, 130, 140, 60)
GUICtrlSetFont (-1, 32)
$frga5 = GUICtrlCreateButton("NEJ", 160, 130, 140, 60)
GUICtrlSetFont (-1, 32)
$frga10 = GUICtrlCreateCheckbox("Fråga inte igen", 305, 150)
GUICtrlSetOnEvent($frga4, "frga6")
GUICtrlSetOnEvent($frga5, "frga7")

While 1
  Sleep(1000)
WEnd

Func frga6()
    If $frga8 = 1 And $frga10<>1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 4", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
        Exit
    ElseIf $frga8 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
        Exit
    ElseIf $frga16 = 1 And $frga10<>1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 6", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
        Exit
    ElseIf $frga16 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
        Exit
EndFunc

Func frga7()
    If $frga15 = 1 And $frga10 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 5", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
        Exit
    ElseIf $frga15 = 1 And $frga10<>1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
        Exit
    ElseIf $frga17 = 1 And $frga10 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
        Exit
    ElseIf $frga17 = 1 And $frga10<>1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
        Exit
    EndIf
EndFunc

Func CLOSEClicked()
  Exit
EndFunc
Edited by TzarAlkex

Share this post


Link to post
Share on other sites
Generator

Which part doesn't work?

Also use Else at the end if ElseIf statement.

Share this post


Link to post
Share on other sites
AdmiralAlkex

Which part doesn't work?

Also use Else at the end if ElseIf statement.

It doesn't happen anything when the checkbox is marked!! I have modified to else at the end but there is no difference.

Share this post


Link to post
Share on other sites
SmOke_N

I hadn't really looked over your code, but in the first example, I'm not sure how you "know" that the second one is the only one firing considering it's exactly the same as the first ElseIf (with the exception that there is another IniWrite() there) (When I say exactly, it's because $frga10 never equals 1).

Anyway, understand that IniRead() returns a "string" nothing else.

So when you say: $frga11 = 1 then really, because $frga11 is a string and 1 is an integer/number, it will not actually be "equal" no matter how autoit lets you cheat at it.

Coding properly tends to help in these situations ... such as:

$frga11 = Int(IniRead('whatever.ini', 'section', 'key', '0'))

Here we define $frga11 as an actual integer, so now we can compare $frga11 to the integer 1.

As far as your checkbox, $frga10 holds the Control ID of the control you made, not what "state" it's in.... Might have a look at GUICtrlGetState() :)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
AdmiralAlkex

I have tried for hours now :):D I am getting tired of this.... It's apparent i am not good enough to get this working.... I give up.... :D :D I will scrap this if not somebody cant fix whatever is wrong....

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$frga8 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 2", "0"))
$frga11 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 4", "0"))
$frga12 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 5", "0"))
$frga13 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 6", "0"))
$frga14 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "0"))
$frga15 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 8", "0"))
$frga16 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 9", "0"))
$frga17 = Int(IniRead(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 10", "0"))

If $frga11 = 1 & $frga8 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
Exit
EndIf

If $frga13 = 1 & $frga8 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
Exit
EndIf

If $frga12 = 1 & $frga15 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
Exit
EndIf

If $frga14 = 1 & $frga15 = 1 Then
    IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
Exit
EndIf

$frga1 = GUICreate("Fråga...", 400, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()
$frga2 = GuiCtrlCreateEdit("Att ändra något här innebär att registret ändras vilket kan vara farligt om något skulle bli fel.", 10, 10, 380, 75, BitOR($ES_MULTILINE, $ES_READONLY), $WS_EX_STATICEDGE)
GUICtrlSetFont (-1, 16)
$frga3 = GUICtrlCreateLabel("Är du säker på att du vill fortsätta??", 35, 95, 350, 25)
GUICtrlSetFont (-1, 16)
$frga4 = GUICtrlCreateButton("JA", 15, 130, 140, 60)
GUICtrlSetFont (-1, 32)
$frga5 = GUICtrlCreateButton("NEJ", 160, 130, 140, 60)
GUICtrlSetFont (-1, 32)
$frga10 = GUICtrlCreateCheckbox("Fråga inte igen", 305, 150)
GUICtrlSetOnEvent($frga4, "frga6")
GUICtrlSetOnEvent($frga5, "frga7")
$frga18 = GUICtrlGetState($frga10)

While 1
  Sleep(1000)
WEnd

Func frga6()
    If $frga8 = 1 And $frga18 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 4", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
        Exit
    ElseIf $frga8 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "1")
        Exit
    ElseIf $frga16 = 1 And $frga18 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 6", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
        Exit
    ElseIf $frga16 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "1")
        Exit
    Else
        Exit
    EndIf
EndFunc

Func frga7()
    If $frga15 = 1 And $frga18 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 5", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
        Exit
    ElseIf $frga15 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 1", "0")
        Exit
    ElseIf $frga17 = 1 And $frga18 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 7", "1")
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
        Exit
    ElseIf $frga17 = 1 Then
        IniWrite(@ScriptDir & "\" & "doscommandsmenusettings.ini", "Registrysettings", "Setting 3", "0")
        Exit
    Else
        Exit
    EndIf
EndFunc

Func CLOSEClicked()
  Exit
EndFunc
Edited by TzarAlkex

Share this post


Link to post
Share on other sites
Jos

Is the & supposed to be AND ?

If $frga11 = 1 And $frga8 = 1 Then

..and you want to do GUICtrlRead($frga18 ) when you want to get its Value..

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
AdmiralAlkex

Is the & supposed to be AND ?

If $frga11 = 1 And $frga8 = 1 Then

..and you want to do GUICtrlRead($frga18 ) when you want to get its Value..

thx for the tip but the checkbox is still not working!!

Share this post


Link to post
Share on other sites
kaz

To test the checkbox :

BitAND(GUICtrlRead($frga10),$GUI_CHECKED) = $GUI_CHECKED

it work for me

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  

×