1.

Solve : Using Evaluate in batch script.?

Answer»

XP Home.

With regard to Dias de VERANO's reply #4 here 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.

CODE: [Select]
@echo off
cls

for /f %%1 in ('evaluate formatnumber(22)') do (
set number=%%1
)
echo %number%

Thanks.Code: [Select]
@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:

Code: [Select]
@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.



Discussion

No Comment Found