G
Guest
Is the following a bug or a feature? Consider the following short MS DOS
batch script from a routine for converting latitude and longitude values into
Flinn-Engdahl region names. Although both a and b are set within the scope of
the ( )'s, references to their values are not correctly resolved until
outside of the ( )'s even though a set without arguments from within the (
)'s shows that they are indeed defined correctly.
==== test.bat
======================================================================================
@echo off
if 1 == 1 (
set a=1
set b=2
set
echo a=%a%
echo b=%b%
)
echo a=%a%
echo b=%b%
***** Condensed output from the set showing that a and b are defined within
the ( )'s:
a=1
ALLUSERSPROFILE=C:\Documents and Settings\All Users
b=2
CommonProgramFiles=C:\Program Files\Common Files
.... etc.
***** References to a and b within the ( )'s DO NOT pick up the values of a
and b:
a=
b=
***** References to a and b outside of the ( )'s DO pick up the values of a
and b:
a=1
b=2
batch script from a routine for converting latitude and longitude values into
Flinn-Engdahl region names. Although both a and b are set within the scope of
the ( )'s, references to their values are not correctly resolved until
outside of the ( )'s even though a set without arguments from within the (
)'s shows that they are indeed defined correctly.
==== test.bat
======================================================================================
@echo off
if 1 == 1 (
set a=1
set b=2
set
echo a=%a%
echo b=%b%
)
echo a=%a%
echo b=%b%
***** Condensed output from the set showing that a and b are defined within
the ( )'s:
a=1
ALLUSERSPROFILE=C:\Documents and Settings\All Users
b=2
CommonProgramFiles=C:\Program Files\Common Files
.... etc.
***** References to a and b within the ( )'s DO NOT pick up the values of a
and b:
a=
b=
***** References to a and b outside of the ( )'s DO pick up the values of a
and b:
a=1
b=2