Computer Hope
Microsoft => Microsoft DOS => Topic started by: Woodman on April 06, 2009, 08:36:06 PM
-
XP Home.
With regard to Dias de Verano's reply #4 here (http://www.computerhope.com/forum/index.php/topic,80530.0.html) is there any way of amending the following script to prevent the runtime error "') was unexpected at this time"?
Evaluate formatnumber(22) returns the correctly formatted number when entered at the command prompt.
@echo off
cls
for /f %%1 in ('evaluate formatnumber(22)') do (
set number=%%1
)
echo %number%
Thanks.
-
@echo off
cls
for /f %%1 in ('evaluate WScript.echo formatnumber(22)') do (
set number=%%1
)
echo %number%
oops... that doesn't work either.
Ahh- but I see from comparing it to Dias's script:
@echo off
cls
for /f %%1 in ('evaluate "formatnumber(22)"') do (
set number=%%1
)
echo %number%
add quotes around the expression.
-
Yes, if you have a closing parenthesis in the dataset part of any FOR construct you need to protect it by quoting. This is a batch requirement, not a vbs thing.
-
Thank you both for the responses and for your patience with us learners.