----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

Parse_Command_Line_Switches

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

Library
Resources

Constants | Functions | GlobalSwitches | GuardNotes | Command Shorthand | MountCommands | Procedures
:Procedures   File_Number_Lines | Parse_Command_Line_Switches | System_Info

:PCLS (Parse_Command_Line_Switches)

Description

Parse a command line for switches. Return the number of switches found, the actual switch characters and .Mount/\Commands to manipulate them.

Syntax

At the Command Prompt

C:\>NTCmdLib   :[PCLS|Parse_Command_Line_Switches] Switches CommandLine

In a Script

CALL NTCmdLib   :[PCLS|Parse_Command_Line_Switches] Switches CommandLine
%.Call%   :[PCLS|Parse_Command_Line_Switches] Switches CommandLine

Parameters and Switches

Switches   VariableName or "Quoted String" containing a space-delimited list of valid switches without prefixes.  For example "a demo s1" would allow your script to accept /a, -a, /demo, -demo, /S1 and -S1.
CommandLine   The entire command line from the calling script, represented as %* or %1 %2 %3 etc.

Errorlevels, Output Variables and Custom Mount/\Commands

Name

 

Value

  Description/Contents

_PCLS_Count

 

4

  Total switches found (includes valid and invalid)

_PCLS_Found

 

a demo

  Variable containing a space-delimited list of switches passed on the command line that were contained in your ValidSwitches list.

_PCLS_Bad

 

b noisy

  Variable containing a space-delimited list of switches passed on the command line that were not in your ValidSwitches list.

_PCLS_Valid

 

a demo S1

  A copy of the ValidSwitches list passed to PCLS.

.PCLS_Shift

 

various

  Remove switches from the original command line, moving the actual (non-switch) parameters into their proper places as %1, %2, etc. (NOTE that %* will remain unchanged!)

.PCLS_Stat

 

various

  Display True/False status of ".if/Switch" and ".ifNot/Switch" custom Mount/\Commands.

.PCLS_List

 

various

  List valid switches that were found.

.if/S1

 

True
or
False

  Evaluates True if switch S1 was specified on the command line, otherwise False.

.ifNot/S1

 

True
or
False

  Evaluates True if switch S1 was NOT specified on the command line, otherwise False.

Examples, Notes and Instructions

Notes

  • Output is displayed to STDOUT, errors to STDERR
  • To suppress console display, use the library GlobalSwitch /Quiet (or simply /q)

    NTCmdLib /Q TaskID /TaskSwitches Parameters

    CALL NTCmdLib /Q TaskID /TaskSwitches Parameters

    %.Call% /Q TaskID /TaskSwitches Parameters

  • On the command line, switches must be separated by spaces and prefixed with - or /.
  • Switches should be alphanumeric only (A-Z, 0-9) and are not case-sensitive.

        /Switch  equals  -switch  equals  /SWITCH

  • There will be always be if/x AND ifNot/x .M/\Cs present for every switch that was passed in the Switches list, regardless of whether that switch was present on the current command line.
  • This allows the MountCommands to be coded into the calling script without generating errors. They will dynamically be assigned as TRUE or FALSE based on the command line that started the current run.

K

E

Y

Common Commands INTERNAL External /SWITCH Parameter Help text AddonTool
Mounted Commands .Mount/\Command CmdShorthand #Constant $FUNCTION :Procedure !GuardNote
Operating Systems NT/2K/XP/K3 NT Only NT/2K 2K Only 2K/XP XP Only XP/K3 K3 Only 2K/XP/K3

Procedures   File_Number_Lines | Parse_Command_Line_Switches | System_Info
/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\