Sign in to follow this  
Followers 0
latoonne

If or then problem

8 posts in this topic

Hello everybody,

Why this expression does not work

If @UserName <> "RCITERNE" or @UserName <> "SDEROSA" Then

MsgBox(64,"Attention", "Installation impossible vous ne disposez pas de la license Crystal Reports."& @CRLF & "Vous devez être loggué avec le profil RCITERNE ou SDEROSA," & @CRLF& " Ils sont les seuls à être en possession d'une license Crystal Reports Developper.")

Exit(1)

Endif

I have always the message box even if i use the good account.

Kind Regards

Share this post


Link to post
Share on other sites



change the OR to AND to make the If correct

Hi,

I cannot change or by and because it's a condition, the syntax is correct, this morning i tried this see below, but same issue.

#include <Array.au3>

Dim $avArray

$avArray = _ArrayCreate("RCITERNE", "SDEROSA")

If @UserName <> $avArray[0] or @UserName <> $avArray[1] Then

MsgBox(64,"Attention", "Installation impossible vous ne disposez pas de la license Crystal Reports."& @CRLF & "Vous devez être loggué avec le profil RCITERNE ou SDEROSA," & @CRLF& " Ils sont les seuls à être en possession d'une license Crystal Reports Developper.")

Exit(1)

else

.

.

EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

I cannot change or by and because it's a condition, the syntax is correct, this morning i tried this see below, but same issue.

Yes you can and your syntax is wrong :whistle:

Read the statement you created out loud for yourself and you will see it is wrong and needs an AND.

Your statement is ALWAYS true since the value will ALways be either NotEqual to "value1" OR "value2"

If @UserName <> "RCITERNE" And @UserName <> "SDEROSA" Then
; this is when @UserName  is something else that the 2 specified names
Else
; this is when @UserName is one of the 2 specified names
Endif

:lmao:

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@latoone: you can still keep using the OR if you can't be convinced that your current syntax is incorrect:

If @UserName = "RCITERNE" Or @UserName = "SDEROSA" Then
; this is when @UserName is one of the 2 specified names
Else
; this is when @UserName  is something else that the 2 specified names
Endif

Note that I changed the '<>' to '=', and reversed the 'this is when' parts. In this way you can keep the Or (though JdeB is perfectly right too, ofcourse).

I would actually recommend this syntax, since a relation between two positive statements are one step easier to wrap your mind around than a relation of two negative statements. Both your syntaxes remind me of factly correct but overly complicated English statements like "I am not not male" meaning that I am male.

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Thanks a lot, and long life to internet community.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

change the OR to AND to make the If correct

I would have written the condition the same way as latoonne but with your very logical second response I now see why I should NOT do this. :whistle:

Surfing the forums is always eye opening . . .

Edited by SkiFreak

Share this post


Link to post
Share on other sites

I would have written the condition the same way as SadBunny but with your very logical second response I now see why I should NOT do this. :whistle:

Surfing the forums is always eye opening . . .

?


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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