|
Answer» I have a script which is passed only one parameter, I am issuing the _PARM as I see it being passed by some application for testing. I am expecting a total of 6 PARAMETERS to be passed. Now if for some reason if there is no sixth parameter, the "if" code for %%F DOES NOT GET executed, and it just drops through. Any ideas how to address this? I cannot used IF DEFINED, it does not work.... The quotes are required as shown in _PARM:
Code: [Select]SET _PARM=parm1 parm2 "file_renamed" "windows_path" "filename" for /f "tokens=1-6* delims= " %%a in ("%_parm%") do ( if "%%a"=="" ( echo VAR1 missing goto :ShowUsage ) ELSE ( SET VAR1=%%a echo VAR1 Defined: %VAR1% >> %MAILLOG% )
if "%%b"=="" ( echo VAR2 missing goto :ShowUsage ) ELSE ( echo VAR2 Defined: %VAR2% >> %MAILLOG% SET VAR2=%%b )
if "%%C"=="" ( echo VAR3 missing goto :ShowUsage ) ELSE ( SET VAR3=%%c echo VAR3 Defined: %VAR3% >> %MAILLOG% )
if "%%d"=="" ( echo VAR4 missing goto :ShowUsage ) ELSE ( SET VAR4=%%d echo VAR4 Defined: %VAR4% >> %MAILLOG% )
if "%%e"=="" ( echo VAR5 missing goto :ShowUsage ) ELSE ( SET VAR5=%%e echo VAR5 Defined: %VAR5% >> %MAILLOG% )
if "%%f"=="" ( echo VAR6 missing goto :ShowUsage ) ELSE ( SET VAR6=%%f echo VAR6 Defined: %VAR6% >> %MAILLOG% ) ) ........... do some other stuff You need DELAYED expansion to change/create a variable AND to use it within the loop.Thank you, issue resolved.
|