- Jun
- 3
- 0
Recently I noticed some unexpected behavior with the Parse function. Not sure if this is WAD. It's definitely been the behavior since at least V25.
If I run this btm file three times (1) with a /d parameter, (2) with a /d 7 parameter, and (3) with no parameters
I get the following results
The first two runs gave me the expected results. But the third run (with no parameters) is returning a 0 when Parse is looking for the switch name or the argument following the switch. If there are no parameters on the command line I would have expected nothing to be returned for those two function calls.
Am I missing something?
If I run this btm file three times (1) with a /d parameter, (2) with a /d 7 parameter, and (3) with no parameters
@echo off
echo.
echo CommandLine: %0 %*
echo.
echo --- Parse looking for Switch
echo Returned Value:%@Parse[".",/d,0]:
echo.
echo --- Parse looking for Argument following Switch
echo Returned Value:%@Parse[".",/d,1]:
echo.
echo --- Parse without asking for a return type (OR'd value)
echo Returned Value:%@Parse[".",/d]:
echo.
echo.
echo.
quit
I get the following results
CommandLine: c:\batfile\TestParse2.btm /d
--- Parse looking for Switch
Returned Value:/d:
--- Parse looking for Argument following Switch
Returned Value::
--- Parse without asking for a return type (OR'd value)
Returned Value:1:
CommandLine: c:\batfile\TestParse2.btm /d 7
--- Parse looking for Switch
Returned Value:/d:
--- Parse looking for Argument following Switch
Returned Value:7:
--- Parse without asking for a return type (OR'd value)
Returned Value:1:
CommandLine: c:\batfile\TestParse2.btm
--- Parse looking for Switch
Returned Value:0:
--- Parse looking for Argument following Switch
Returned Value:0:
--- Parse without asking for a return type (OR'd value)
Returned Value:0:
The first two runs gave me the expected results. But the third run (with no parameters) is returning a 0 when Parse is looking for the switch name or the argument following the switch. If there are no parameters on the command line I would have expected nothing to be returned for those two function calls.
Am I missing something?