Something that does not seem possible...

  • Thread starter mathewsdw@sbcglobal.net
  • Start date
M

mathewsdw@sbcglobal.net

Guest
Here is a short sequence of code (unchanged!) that is in a much-larger .bat file:

@Echo On
Set Version=V%@ExecStr[GetVersionString]
Iff %_EXECSTR != 0 Then
@EchoErr Error getting version string!
Quit 16
EndIff
Set NameFile=%@UnQuote[%Prefix]%@Left[11,%Version]%@UnQuote [%Extension]
@Echo ======= NameFile: %NameFile
Set N*

Here is the output from the above code sequence:

Set Version=V2009-04-06-16-10-07
Iff %_EXECSTR != 0 Then
Set NameFile=ABC.V2009-04-06.DEF
======= NameFile: ""
Set N*
NameFile=ABC.V2009-04-06.DEF
NN=2
NUMBER_OF_PROCESSORS=2

The problem is that "NameFile" has either no value (or the value "", I haven't really looked into which...) immediately after the above code in the batch file. However, if I extract the above code into a new, separate, batch file, the output is as expected. I have been fooling with this for literally hours with absolutely no positive results! What is going on/what am I doing wrong/what am I missing/how can I fix it??? Please help me???

P. S. Note that there are no quotes in the line "@Echo ======= NameFile: %NameFile" or in the variable as-listed in the "Set N*" command, but that there are quotes in the displayed output!

P. P. S. Since this code works as expected when extracted into new, separate batch file, you probably can't test it yourself without having access to the much-larger containing batch file..) (I will post/e-mail that if anyone is interested...)

P. P. P. S. This code is at the "heart" of the much-larger batch file (that I feel I really need which is why I am writing it...), so it is absolutely imperative that it work correctly!
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
The only thing I can think of is make sure there are no foreign characters
in your batch file. Sometimes extra nulls or 0x255's seem to show up for
odd reasons.

Have you tried deleting the troublesome lines and re-typing them?

Have you tried putting that snippet of code in its own batch script and
CALLing it from your main script?

You can make it a subroutine also and call it in an external file using
the GOSUB "filename" label syntax.

-Scott

"mathewsdw@sbcglobal.net" <> wrote on 04/06/2009
06:12:02 PM:


> Here is a short sequence of code (unchanged!) that is in a much-
> larger .bat file:
>
> @Echo On
> Set Version=V%@ExecStr[GetVersionString]
> Iff %_EXECSTR != 0 Then
> @EchoErr Error getting version string!
> Quit 16
> EndIff
> Set NameFile=%@UnQuote[%Prefix]%@Left[11,%Version]%@UnQuote [%Extension]
> @Echo ======= NameFile: %NameFile
> Set N*
>
> Here is the output from the above code sequence:
>
> Set Version=V2009-04-06-16-10-07
> Iff %_EXECSTR != 0 Then
> Set NameFile=ABC.V2009-04-06.DEF
> ======= NameFile: ""
> Set N*
> NameFile=ABC.V2009-04-06.DEF
> NN=2
> NUMBER_OF_PROCESSORS=2
>
> The problem is that "NameFile" has either *no value* (or the value
> "", I haven't really looked into which...) immediately after the
> above code in the batch file. However, if I extract the above code
> into a new, separate, batch file, the output is *as expected*. I
> have been fooling with this for literally*hours* with *absolutely no
> positive results*! What is going on/what am I doing wrong/what am I
> missing/how can I fix it??? *Please* help me???
>
> P. S. Note that there are *no quotes* in the line "@Echo =======
> NameFile: %NameFile" or in the variable as-listed in the "Set N*"
> command, but that there *are* quotes in the displayed output!
>
> P. P. S. Since this code works *as expected* when extracted into
> new, separate batch file, you probably can't test it yourself
> without having access to the much-larger containing batch file..)
> (I will post/e-mail that if anyone is interested...)
>
> P. P. P. S. This code is at the "heart" of the much-larger batch
> file (that I feel I *really need* which is why I am writing it...),
> so it is *absolutely imperative* that it work correctly!
>
>
>
>
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
The problem is that "NameFile" has either no value (or the value "", I haven't really looked into which...) immediately after the above code in the batch file. However, if I extract the above code into a new, separate, batch file, the output is as expected. I have been fooling with this for literally hours with absolutely no positive results! What is going on/what am I doing wrong/what am I missing/how can I fix it??? Please help me???

Have you tried running the full (problematic) batch in the debugger, with a breakpoint at the start of the misbehaving section?
 
Similar threads
Thread starter Title Forum Replies Date
vefatica @EXECSTR ... TCSTART ... something's wrong! Support 7
vefatica Something got very slow (very recently) Support 1
L How to? Shebang, nice idea but am I missing something? Support 4
P Can't do something to a file and then delete it? Support 6
vefatica Something is hosed in build 74 Support 10
M Hotkey-mechanism, for doing something with the current command-line Support 4
M Yet another strange something re something called "@TCONVERT" Support 8
vefatica Something wrong with @PID Support 10
M Is this a restriction I wasn't aware of or something new (that maybe shouldn't be there)? Support 16
vefatica Append something entered to a file? Support 12
D Parsing an array variable to an array does not work Support 5
J Take command does not start on Windows 10 Support 3
J ffind does not find files Support 4
Joe Caverly PAUSE does not erase countdown timer Support 0
D ParentDirectory does not update directory history Support 6
D Documentation Help "Startup" page does not describe global lists Support 0
Charles Dye Does HASH's /E option do anything? Support 1
fishman@panix.com First TCC instantiation after reboot does not work. Support 17
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
vefatica Why does @WSLPATH double the leading '/'? Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
Peter Murschall WAD rem does not work correctly Support 8
vefatica Does @SYMLINK work? Support 6
R Tree on FAT32 does not sort by name by default. Support 6
A Tcc does not recognize "bcdedit" Support 20
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17
M Ctrl-C when using command line history does nothing Support 2
vefatica JOBS /K ... how does it work? Support 5
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
D Does TCC improve CMD's implementation of ECHO? Support 6
vefatica Find Files/Text dialog: does it work? Support 0
Alpengreis [v22.00.41] sync command flag "/X" does not work Support 22
Joe Caverly .PS1 script does not work with PSHELL Support 11
M MOVE does not behaves like intended (on failure) Support 1
R Fixed Sendmail parameter /USER= does not work Support 4
twaterloo does tcc have a task sceduler Support 4
Brian Woodward How to? Does FTP.CFG only support SSL over port 21? (Newbie) Support 6
M Activation Key does not correspond… Support 2
James Miller tcc shell window does not disappear Support 18
D Lua does not work on the commandline Support 5
D Fresh instance of TCMD does not use TCMD.INI Support 7
D Fixed @Lua does not behave as documented Support 8
D everything /o does not open the option dialog Support 4
M Why does HELP keep opening in the background? Support 0
vefatica Does TCC know I'm visiting the forums? Support 76
vefatica Why does my forum theme keep changing? Support 1
fishman@panix.com 19.02.37 Does Not Install For Me Support 2
I Windows 10 console does not allow alt-F4 alias to complete Support 1
fromano WAD ver /r does not detect Win 10B10166 Support 5
Alpengreis Fixed BATCOMP /O does not work Support 1

Similar threads