# compare variables

## Recommended Posts

ok guys, i feel silly to ask you this, but i'm having a very odd issue....

what i want to do:

compare four variables to get the less one, when the less one is found check if it is less then three.... (very, VERY, simple.... -_-")

the issue thet i get:

the first variable that i imput result alwayi the less one.... AND i really don't understand why....

please let me understand my errors, thank you....

```While 1

;\$A=InputBox(0,"NUMBER A","")
;\$B=InputBox(0,"NUMBER B","")
;\$C=InputBox(0,"NUMBER C","")
;\$D=InputBox(0,"NUMBER D","")

\$A=9
\$B=6
\$C=1
\$D=4

MsgBox(0,"","CALCULATING THE MINOR NUMBER")

Select
Case \$A<=\$B & \$A<=\$C & \$A<=\$D
MsgBox(0,"","A IS THE MINOR NUMBER")
IF \$A<3 Then
MsgBox(0,"","A IS LESS THEN 3")
EndIf

Case \$B<=\$A & \$B<=\$C & \$B<=\$D
MsgBox(0,"","B IS THE MINOR NUMBER")
IF \$B<3 Then
MsgBox(0,"","B IS LESS THEN 3")
EndIf

Case \$C<=\$A & \$C<=\$B & \$C<=\$D
MsgBox(0,"","C IS THE MINOR NUMBER")
IF \$C<3 Then
MsgBox(0,"","C IS LESS THEN 3 ")
EndIf

Case \$D<=\$A & \$D<=\$B & \$D<=\$C
MsgBox(0,"","D IS THE MINOR NUMBER")
IF \$D<3 Then
MsgBox(0,"","D IS LESS THEN 3")
EndIf
EndSelect

MsgBox(0,"","END PROGRAM")

WEnd```

##### Share on other sites

& is the string concatenation operator. Use AND instead.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

You can also make your life simpler by using _Min() function (see help).

`_Min(_Min(\$a, \$b), _Min(\$c, \$d))`

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

What jchd said, but as you come from another language it appears, you know the difference between & and &&?

eh no, i don't know the differences.... -_-" adn yes, i'm from others "basic like" languages, i've used autoit only for simple scripts....

& is the string concatenation operator. Use AND instead.

YES, that is the problem!! i've searched for comparison operators in autoit, but nothing like the simple "And" was listed.... thank you very much!!

You can also make your life simpler by using _Min() function (see help).

`_Min(_Min(\$a, \$b), _Min(\$c, \$d))`

This function is very useful and i will use it in the future, but right now i need something that return me the variable with the minor number, not the number itself.... Thank you anyway, your help is really appreciated!!

##### Share on other sites

OK, google "&& vs &" as I don't want to repeat what has been said before. There is a BIG difference.

Plus from what I understand (which isn't much) other BASIC-like languages have And too, with & being the concat operator. So I'm slightly confused if you have prior knowledge of "other basic like" languages, as you've been using those wrong too.

##### Share on other sites

probably the second one....

As i said to jchd, i've searced in google for comparison operator in autoit, and used what i've found.... (nothing about the And)

i was shallow....

##### Share on other sites

Your primary source of information is still the help file: Language Reference > Operators

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

As i said to jchd, i've searced in google for comparison operator in autoit, and used what i've found.... (nothing about the And)

And is a logical operator whereas == is a comparison operator. My point is most BASIC-like languages share the same grammar, so if you have been doing i == 1 & j == 2 in other BASIC-like languages, then you have been doing it wrong there too.

https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm

Edit: Oh and searching "AutoIt & operator" gave me the link above as the top result. Then from there it would have been clear as to why it wasn't working.

Edited by guinness

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...