Jump to content

If or then problem


Recommended Posts

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

Link to comment
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

Link to comment
Share on other sites

  • Developers

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

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

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...