View unanswered posts | View active topics It is currently 22 Nov 2014 21:19



Post new topic Reply to topic  [ 5 posts ] 
Help with the "gtr" "lss" etc arguments in the "if" command 
Author Message

Joined: 01 Sep 2011 03:54
Posts: 147
Location: Perth, Western Australia
Post Help with the "gtr" "lss" etc arguments in the "if" command
Hi,
Could someone give me a simple sintax overview to the various arguments involving "gtr" "lss" etc in the "if" command.

Any help would be greatly appreciated,
Rileyh


12 Sep 2011 22:13
Profile

Joined: 07 Sep 2011 18:32
Posts: 20
Location: Eastern Australia
Post Re: Help with the "gtr" "lss" etc arguments in the "if" comm
have you looked at IF /? :?:


13 Sep 2011 16:54
Profile

Joined: 01 Sep 2011 03:54
Posts: 147
Location: Perth, Western Australia
Post Re: Help with the "gtr" "lss" etc arguments in the "if" comm
@bob d
Yes I have looked at that and it is quite hard to understand.
Also it is very brief and has not much info on it

Rileyh


13 Sep 2011 20:44
Profile

Joined: 01 Jul 2011 08:47
Posts: 114
Post Re: Help with the "gtr" "lss" etc arguments in the "if" comm
See the code and test with different numbers to understand this:
Code:
@echo off
cls
echo.
echo  Overview of the various comparison operations in the command IF
echo.
set /p val1= value 1:
set /p val2= value 2:
echo.
echo   IF %val1% EQU %val2% (command if TRUE) ELSE command if FALSE
IF %val1% EQU %val2% (ECHO     TRUE) ELSE ECHO     FALSE
echo.
echo   IF %val1% NEQ %val2% (command if TRUE) ELSE command if FALSE
IF %val1% NEQ %val2% (ECHO     TRUE) ELSE ECHO     FALSE
echo.
echo   IF %val1% LSS %val2% (command if TRUE) ELSE command if FALSE
IF %val1% LSS %val2% (ECHO     TRUE) ELSE ECHO     FALSE
echo.
echo   IF %val1% LEQ %val2% (command if TRUE) ELSE command if FALSE
IF %val1% LEQ %val2% (ECHO     TRUE) ELSE ECHO     FALSE
echo.
echo   IF %val1% GTR %val2% (command if TRUE) ELSE command if FALSE
IF %val1% GTR %val2% (ECHO     TRUE) ELSE ECHO     FALSE
echo.
echo   IF %val1% GEQ %val2% (command if TRUE) ELSE command if FALSE
IF %val1% GEQ %val2% (ECHO     TRUE) ELSE ECHO     FALSE

If you want use the value as string use the quotation marks.

IF "%val1%" LSS "%val2%" ECHO The first word is alphabetically before the second word.
IF /I "%val1%" EQU "%val2%" ECHO Lowercase and uppercase are ignored - ABC is the same as abc

Robert


14 Sep 2011 02:43
Profile

Joined: 01 Sep 2011 12:52
Posts: 34
Post Re: Help with the "gtr" "lss" etc arguments in the "if" comm
BASIC:

Code:
line1: if VARIABLE1 gtr VARIABLE2 goto 1greaterthan2
line2: if VARIABLE1 lss VARIABLE2 goto 1lessthan2
line3: if VARIABLE1 equ VARIABLE2 goto 1equal2
line4: if VARIABLE1 neq VARIABLE2 goto 1notequal2
line5: if VARIABLE1 leq VARIABLE2 goto 1lessorequal2
line6: if VARIABLE1 geq VARIABLE2 goto 1greaterorequal2


Explaination:

line1: if the first variable (VARIABLE1) is greater than the second (VARIABLE2) then skip to 1greaterthan2

line2: if the first variable (VARIABLE1) is less the second (VARIABLE2) then skip to 1lessthan2

line3: if the first variable (VARIABLE1) is equal the second (VARIABLE2) then skip to 1equal2

line4: if the first variable (VARIABLE1) is not equal the second (VARIABLE2) then skip to 1notequal2

line5: if the first variable (VARIABLE1) is less or equal the second (VARIABLE2) then skip to 1lessorequal2

line6: if the first variable (VARIABLE1) is greater or equal the second (VARIABLE2) then skip to 1greaterorequal2


Hope this helped!
-Exouxas


14 Sep 2011 02:57
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.