Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://stackoverflow.com/a/1292079/5079799

If you are here to parse optional arguments, you like would be better using → Named Arguments

@ECHO OFF
setlocal enableextensions enabledelayedexpansion
call :getargc argc %*
::echo Count is %argc%
::echo Args are %*

:Check is first Arg "Double Sided?"
SET ARG2="%~2" 
IF %argc% GTR 1 (
 IF %ARG2%=="Double_Sided" (
  SET SINGLEORDOUBLESIDED=Double_Sided
 )
)
::ECHO 1
::ECHO %SINGLEORDOUBLESIDED%

::If not, Set default of "Single_Sided" and therefor 2nd arg is "PRINTOPTS"
IF NOT DEFINED SINGLEORDOUBLESIDED (
 SET SINGLEORDOUBLESIDED=Single_Sided
 SET PRINTOPTS="%~2"
)
::ECHO 2
::ECHO %SINGLEORDOUBLESIDED%
::ECHO %PRINTOPTS%

::If more than 2 Args, the 1st MUST = FilePath, 2nd = Double_Sided and 3rd = PRINTOPTS
IF %argc% GTR 2 (
 SET PRINTOPTS="%~3"
)
::ECHO 3
ECHO Single or Double Sided = %SINGLEORDOUBLESIDED%
ECHO PRINTOPTS = %PRINTOPTS%
  • No labels