----^--->
/\

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

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

PAD

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

 

Library
Resources

Constants | Functions | GlobalSwitches | GuardNotes | Command Shorthand | MountCommands | Procedures
Functions   CENTER | DEQUOT | ESC | FCOUNT | LEN | PAD | SCOUNT | SEQNUM | WAITFOR

$PAD (PAD a string to a specified length)

Description

PAD a variable's contents or a "Quoted String" to a specified TotalLength with the option to specify a custom PadCharacter.  Padding can be standard (padding on the left) or Reversed (padding on the right).

Syntax

At the Command Prompt (library IS NOT initialized)

C:\>NTCmdLib $PAD VariableName|"Quoted String"
TotalLength ["PadCharacter"] [R]

At the Command Prompt (library IS initialized)

C:\>L $PAD VariableName|"Quoted String" TotalLength
["PadCharacter"] [R]

In a Script (library IS NOT initialized)

CALL NTCmdLib $PAD VariableName|"Quoted String"
TotalLength ["PadCharacter"] [R]

In a Script (library IS initialized)

%.Call% $PAD VariableName|"Quoted String" TotalLength
["PadCharacter"] [R]

Parameters and Switches

VariableName   Name of a variable containing a string to be padded.
"Quoted String"   A literal string to be padded.
PadCharacter   The character to pad with (a single "quoted" character only!)
R   Reverse the pad (i.e., pad after the target, on the right side)

Errorlevels, Output Variables and Custom Mount/\Commands

Name

 

Value

  Description/Contents

_PAD

 

$77.14******

......text

  Variable containing the padded output

 

ErrorLevel

 

Description/Contents

0

  Success

2

  Missing or invalid parameter

Examples, Notes and Instructions

Example 1 - standard usage with "Quoted String" and custom PadCharacter

C:\GuardPost>NTCmdLib -Quiet $PAD "3" 5 "+"

 

C:\GuardPost>SET _PAD

_PAD=++++3

Nothing is displayed because of GlobalSwitch -Quiet, but the padded output is returned in variable _PAD.

Example 2 - standard usage with an undefined VariableName, custom PadCharacter, in a script with library already initialized.

%.Call% $PAD var 4 "\"

returns "var=\\\\" - if var was undefined

Example 3 - standard usage with a defined VariableName in a script without library already initialized.

CALL NTCmdLib $PAD var 6

returns "var=<space><space>text" - if var=text before padding

Example 4 - reversed usage with a with "Quoted String" and custom PadCharacter

C:\GuardPost>NTCmdLib $PAD "$77.14" 12 "*" R


  ^   =========================================================================
 /!\    NTCmdLib.cmd 2004.03.28 NT/2K/XP/K3 ("Almost Freeware" at $9 or less!)
/LIB\ =========================================================================

_PAD=$77.14******
 

C:\GuardPost>SET _PAD

_PAD=$77.14******

  • First parameter quoted indicates a literal string to pad (minus the quotes). First parameter NOT quoted indicates the name of a variable to pad.
  • If VariableName doesn't exist, it will be created. In that case, VariableName will be a string of PadCharacters with a length of TotalLength.
  •  $SEQNUM is more efficient than $PAD for padding numbers with 0's as in 0001, 0002, etc.
  • 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


Related .Mount/\Commands, #Constants, $Functions, :Procedures

Resource

  Short Description
     

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

Functions   CENTER | DEQUOT | ESC | FCOUNT | LEN | PAD | SCOUNT | SEQNUM | WAITFOR

/\
//\\
//
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\