jeudi 12 avril 2018

Check if array variable is empty in Windows batch

I have the program below (simplified).

The fact is that table variable can contain none, one or several string values:

set table=
REM set table=geo1
REM set table=geo1,geo2,geo3

if [%table%]==[] (goto :end)

for %%a in %table% do (

    REM Some commands...

)

:end

REM Some commands...

If table= or table=geo1, no problem. The program is behaving as wanted.

If table=geo1,geo2,geo3 (several values), the program is closing immediatly even with a pause command at the end.

Is there a simple way to check wether a variable is empty or not, being an array or a single string?

Aucun commentaire:

Enregistrer un commentaire