Welcome!

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

SignUp Now!

Parsing problem? (IFF, "", &)

May
238
2
TCC 10,00,67 Windows XP [Version 5,1,2600]

I encountered a strange phenomenon when debugging a batchfile using IFF.

Here's a simplified illustration.

PHP:
@echo off

alias mystart=`iff "%@unquote[%1]" == "." .AND. %# == 1 then & echo start dot & else & (echo start %$) & endiff`

echo.
echo Test 1 - direct arg
echo.

mystart .
mystart "."
mystart "q&a.txt"

echo.
echo Test 2 - arg via variable
echo.

mystart .
mystart "."
set arg="q&a.txt"
mystart %arg%
The output should be the same in both cases, but that is not the case.

PHP:
14:39 (2009-06-22) C:\User\fl>test

Test 1 - direct arg

start dot
start dot
C:\User\fl\test.btm [11]  Usage : IFF [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] THEN & commands
TCC: C:\User\fl\test.btm [11]  Unknown command "a.txt]"
start dot
TCC: C:\User\fl\test.btm [11]  Unknown command "else"
start "q&a.txt"
TCC: C:\User\fl\test.btm [11]  Unknown command "endiff"

Test 2 - arg via variable

start dot
start dot
start "q&a.txt"
The problem seems to be using IFF to compare strings with embedded '&' characters. But only when giving the problem string directly to the alias using IFF, if the argument is provided via an environmen variable it works as expected.
 

Similar threads

Back
Top