I'm starting with batch and I need to do a simple exercise, but I have a few problems.
In the exercise I need to introduce 3 parameters with cmd
and check that there are only 3, no more, no less. Then I need to check each parameter to see if everyone equals a letter, (%1
should be a
, %2
b
and %3
c
).
@echo off
if (%1=="") (goto end) else (goto c1)
:c1
if ("%2" =="") (goto error) else (goto c2)
:c2
if ("%3" =="") (goto error) else (goto c3)
:c3
if (%4=="") (goto c4) else (goto c4)
:c4
if ("%1"=="a") (goto p1) else (goto conditions)
:p1
if ("%2"=="b") (goto p2) else (goto conditions)
:p2
if ("%3"=="C") (goto end) else (goto conditions)
goto end
:error
echo "Error"
goto fin
:conditions
echo "Error with parameters"
:end