Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

conditional expression: force numeric

Jan
40
0
Hi. I have a batch file in which I use querybox to get a %ans that is numeric. I want to a conditional expression that is numeric, but I'm not getting a numerical comparison in an IFF statement.

IFF %ans == 1 works, but %ans GE 1 does not work.

How do I get the numerical commparison to work?

Thx
 
How does it fail? It seems OK here.
Code:
v:\> type qb.btm
querybox /cue="CUE" /d "TITLE" PROMPT %%foo
echo foo is %foo
iff %foo GE 1 then
        echo %%foo is GE 1
else
        echo %%foo is not GE 1
endiff

v:\> qb.btm
foo is 2
%foo is GE 1
 
do forever
set ans=2
querybox /D /E /T10 "Timeout in 10" 1=Epic only; 2=both %%ans
if %_? == 2 iterate

delay 1
IFF %ans == 1 .OR. %ans == 2 THEN
activate "*hyperspace - FHMC*" restore
delay 1
click /L /2 1000 500
delay 2
click /L /2 1300 500
delay 1
click /L 1000 400
delay 1
click /L 1300 300
delay 2
activate "*hyperspace* - FHMC*" bottom
delay 2
Window min
ENDIFF

IFF %ans == 2 THEN
activate "PowerScribe*" restore
delay 1
click /L /2 1000 500
delay 2
activate "PowerScribe*" min
ENDIFF
enddo

The code does not select the first IFF statement when I edit the %ans from 2 to be 1. I did not test the case when I accept the default of 2
 
I don't know what's failing, but the logic seems OK. Below, I entered 1, then 2, then 1, then 2, then 3.
Code:
v:\> type qb.btm
do forever
set ans=2
querybox /D /E /T10 "Timeout in 10" 1=ONE; 2=TWO %%ans
if %_? == 2 iterate

delay 1
IFF %ans == 1 .OR. %ans == 2 THEN
        echo First IFF: ans = %ans
ENDIFF

IFF %ans == 2 THEN
        echo Second IFF: ans = %ans
ENDIFF

if %ans == 3 quit
enddo

v:\> qb.btm
First IFF: ans = 1
First IFF: ans = 2
Second IFF: ans = 2
First IFF: ans = 1
First IFF: ans = 2
Second IFF: ans = 2
 
I was unclear. I posted the version that works. I wanted the first conditional to be
IFF %ans GE 1 THEN
echo First IFF: ans = %ans
ENDIFF
 
It still seems OK. As before, I tested with 1,2,1,2,3.
Code:
v:\> type qb.btm
do forever
set ans=2
querybox /D /E /T10 "Timeout in 10" 1=ONE; 2=TWO %%ans
if %_? == 2 iterate

delay 1
IFF %ans GE 1 THEN
        echo First IFF: ans = %ans
ENDIFF

IFF %ans == 2 THEN
        echo Second IFF: ans = %ans
ENDIFF

if %ans == 3 quit
enddo

v:\> qb.btm
First IFF: ans = 1
First IFF: ans = 2
Second IFF: ans = 2
First IFF: ans = 1
First IFF: ans = 2
Second IFF: ans = 2
First IFF: ans = 3
 
I think the problem was my echo statement. Which was originally
echo answer >= 1, ans is %ans

I think that greater symbol was interpreted as a redirection character. When I changed that echo statement, it started to work.

Thanks. I'm glad I posted.
 
Back
Top
[FOX] Ultimate Translator
Translate