[Toc][Index]

SHIFT - Shift batch file parameters

 
 Purpose:    Allows the use of more than 127 parameters in a batch file. 
             
 Format:     SHIFT [n | /n ] 
             
             n :  Number of positions to shift. 
 
 Usage 
 SHIFT is provided for compatibility with older batch files, where it was 
 used to access more than 10 parameters.  CMD.EXE supports 128 parameters 
 (%0 to %127), so you may not need to use SHIFT for batch files running 
 exclusively under JP Software command processors. 
 SHIFT moves each of the batch file parameters n positions to the left. 
  The default value for n is 1.  SHIFT 1 moves the parameter in %1 to 
 position %0, the parameter in %2 becomes %1, etc.  You can reverse a 
 SHIFT by giving a negative value for n (i.e., after SHIFT -1, the former 
 %0 is restored, %0 becomes %1, %1 becomes %2, etc.). 
 SHIFT also affects the parameters %n$. (command-line tail) and %# (number 
 of command arguments). 
 For example, create a batch file called TEST.BAT: 

 
         echo %1 %2 %3 %4
         shift
         echo %1 %2 %3 %4
         shift 2
         echo %1 %2 %3 %4
         shift -1
         echo %1 %2 %3 %4
 
 
 Executing TEST.BAT produces the following results: 

 
         [c:\] test one two three four five six seven
         one two three four
         two three four five
         four five six seven
         three four five six
 
 
 If you add a slash before the value n, the value determines the postion 
 at which to begin the shift.  For example: 

 
         shift /2
 
 
 leaves parameters %0 and %1 unchanged, and moves the value of %3 to 
 postion %2, %4 to %3, etc.  The value after the slash cannot be negative, 
 and shifts performed with the slash cannot be undone later in the batch 
 file. 

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs