How to? A seemingly-stupid question related to the "Shift" command.

May 24, 2010
855
0
Northlake, Il
My goal is simple: If a certain parameter occurs I want to delete if from the list of parameters.

I think showing a complete transcript is the best route to go here:

Code:
   Thu  Jan 19, 2012   4:52:28p

ISO8601 plugin v1.1.1 loaded.
SafeChars plugin v1.5.7 loaded.
Sift v0.55.0 loaded.

TCC  12.11.76   Windows 7 [Version 6.1.7601]
Copyright 2011  Rex Conn & JP Software Inc.  All Rights Reserved
Registered to Daniel Mathews

[Z:\]Type TestShift.btm
@Echo Off
SetLocal
Set I=1
Do While %I LE %#
   Set Arg=%[%I]
   Iff "%@Left[2,%Arg]" == "/Z" Then
      @Echo On
      Shift -%I
      @Echo Off
   EndIff
   @Echo I: %I   %@Format[-3.3,%[%I] ]  %%$: %$
   Set /A I+=1
EndDo
EndLocal
Quit 0

[Z:\]TestShift a b c /z e f g
I: 1   a    %$: a b c /z e f g
I: 2   b    %$: a b c /z e f g
I: 3   c    %$: a b c /z e f g
Shift -4
I: 4   /z   %$: a b c /z e f g
I: 5   e    %$: a b c /z e f g
I: 6   f    %$: a b c /z e f g
I: 7   g    %$: a b c /z e f g


Simply put, that did not work at all (in fact, it seems to have done absolutely nothing), so below is a reasonable second try (although I expected the code above to work; not really so for the following code in which I simply deleted the minus sign in front of the "%I" on the "Shift" command):

Code:
[Z:\]type TestShift.btm
@Echo Off
SetLocal
Set I=1
Do While %I LE %#
   Set Arg=%[%I]
   Iff "%@Left[2,%Arg]" == "/Z" Then
      @Echo On
      Shift %I
      @Echo Off
   EndIff
   @Echo I: %I   %@Format[-3.3,%[%I] ]  %%$: %$
   Set /A I+=1
EndDo
EndLocal
Quit 0

[Z:\]TestShift a b c /z e f g
I: 1   a    %$: a b c /z e f g
I: 2   b    %$: a b c /z e f g
I: 3   c    %$: a b c /z e f g
Shift 4
I: 4        %$: e f g


So I was, in fact, correct in that expectation.

Simply put: What don't I understand? What am I doing wrong?

- Dan
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Dan,

I assume the goal is to turn a command line of "a b c /z e f g" into "a b c e f g".

You should use SHIFT /n.

I modified your first script and replaced the minus sign with a slash. I get this output:

Code:
foo a b c /z e f g
I: 1   a    %$: a b c /z e f g
I: 2   b    %$: a b c /z e f g
I: 3   c    %$: a b c /z e f g
Shift /4
I: 4   e    %$: a b c e f g
I: 5   f    %$: a b c e f g
I: 6   g    %$: a b c e f g
 
May 24, 2010
855
0
Northlake, Il
Thank you, Scott. I just found the problem myself (both bad eyesight and the fact that the "help" command somewhat strangely started "misbehaving" so badly - it totally and completely "hung" every TCC session in which I entered it - "non-elevated" or elevated, and the Task Manager was totally unable to "kill" ("Access Denied") any of these "hung" TCC sessions). I actually had to reboot this machine to "cure" the problem - and even the "reboot" process seemed to have a "hard time" "killing" these "hung" TCC sessions - I got a series of "complaints" of some kind I really didn't fully understand, although it ultimately succeeded - which takes at least 20 minutes) and I was going to come here and delete this posting had nobody responded to it yet. Sorry!

- Dan
 
Similar threads
Thread starter Title Forum Replies Date
M A possibly stupid question about the "del" command... Support 7
A Stupid, obvious question - launch a BAT with TC Support 10
M Maybe Maybe I'm being stupid (again), but a simple question... Support 4
M How to? A probably stupid question re "@Files" and Include Lists... Support 2
M A probably stupid question about .btm file argument parsing... Support 6
C forum Posting Question... Support 3
C question re: Move Support 3
S How to? Upgrade Question: What supporting documentation is required at time of purchase? Support 2
Peter Murschall Documentation Question to %@PSHELL Support 4
Fross Tab Question Support 6
Fross Quick Function Question Support 17
Dick Johnson Question about the Touch command Support 0
rps Documentation "Copy+Paste+run" question Support 2
vefatica SFTP question Support 17
vefatica Question about IPWorks Support 0
C How to? SHORTCUT question..... Support 6
vefatica TPIPE, crash and question Support 1
C Question / Suggestion Support 1
MickeyF Another TPIPE question Support 6
vefatica Another @EVERYTHING question Support 4
mikea How to? %@everything[] question Support 10
A License Question for Single User Support 5
Jay Sage Help Correction (and Related Question) Support 0
S Elapsed time in TCC prompt question Support 0
H command line parsing question Support 5
C Forum question Support 2
B Newbie here, I have a question. Support 4
J Dumb Question ... Support 4
Timothy Byrd Updating from TC 9 to TC 17 - TCTOOLBAR question Support 2
M A just out of curiosity question re @DiskTotal Support 4
Fross Status Bar Time Question Support 1
C How to? GLOBAL question Support 5
vefatica OT: VisualStudio question Support 1
vefatica Wildcard question Support 4
Dan Glynhampton v15 installer question Support 2
C Move question with Encrypted file... Support 6
C Message Board question Support 1
James Miller How to? filename completion question Support 1
C coding question Support 3
M A just-out-of-curiosity question because it's ... Support 6
Frank question to FOLDERMONITOR Support 14
C Dumb titleprompt question Support 4
M Upgrade Question Support 2
S option /u question Support 19
M Just an out-of-curiosity question re. "Do ... /P ..." Support 31
M How to? An admittedly somewhat silly question regarding elevation... Support 2
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
M PDir format question... Support 3
M A question about file compression that is just out of curiosity... Support 2
M How to? A very simple question re. the current line number in a batch file... Support 2

Similar threads