Something that does not seem possible...

#1
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,270
11
Solon, OH, USA
#2
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

"[email protected]" <> 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
3,552
46
Albuquerque, NM
prospero.unm.edu
#3
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?