darkoshi: (Default)
Trying to figure out how to get the logic in a big Windows batch file to work right is about driving me crazy.

I keep running up against walls for the things that ought to be *simple*.
Like echoing a variable value.
Like comparing a variable to another value.

Sheeesh!

Consider the following.
-----------------------

for /f "tokens=1,2*" %%a in (tmp.txt) do (

SET var1=%%a
SET var2=%%b
SET var3=%%c

echo %%c xxx

setlocal enableDelayedExpansion

echo !var3!
echo "!var3!"
)
------------------------

Why does the 1st ECHO statement display an output with the 'xxx' *before* and partially *overlaying* the value that was read from the file, like this???
xxxIYUIYOIYI

The 2nd ECHO statement displays the correct value.

The 3rd ECHO statement displays the first double-quote character, then the correct variable value. But it doesn't display the 2nd double-quote character. WHY NOT??? How can I figure out if there are spaces on the end, if it doesn't let me display anything after it??

Heaven forbid what I really want to do is like this:
IF "!var3:~19!" == " " call :someOtherFunction
or like this:
IF "!var3:~-2!" == " " call :someOtherFunction


How can I figure out why the If statements aren't working, if I can't even get a simple ECHO to work right?

If I replace the double quote chars in the ECHO statement with some other chars, it still has the same problem.

It doesn't help that I was up til 2am working on this batch file last night, and was only able to get 5.5 hours sleep. Due to waking up early and not being able to fall back asleep.
On top of having woken up 1.5 hours early yesterday morning.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

March 2026

S M T W T F S
12345 6 7
8910111213 14
15 16 171819 2021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Wednesday, March 25th, 2026 12:06 pm
Powered by Dreamwidth Studios