toLower Name dependent?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: toLower Name dependent?

#16 Post by Ed Dyreen » 06 Jun 2011 05:38

@jeb
However, it shows a new effect.

I discovered this too and already applied the technique:
My contribution, a function definitions list :arrow:
http://www.dostips.com/forum/viewtopic.php?f=3&t=1893

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: toLower Name dependent?

#17 Post by dbenham » 06 Jun 2011 05:53

jeb wrote:However, it shows a new effect.

Code: Select all

@echo off
setlocal EnableDelayedExpansion
for %%s in ("s-content") do (
   echo loop1 loopvar-s=%%s
   call :test
)
exit /b

:test
echo test1 loopvar-s=%%s
for %%a in ("a-content") do (
   echo loop2 loopvar-a=%%a
   echo loop2 loopvar-s=%%s
)
exit /b
Now you can see, even in a sub function you could access for-loop vars from outside,
if you start your own local for-loop.
Yes - I was a bit shocked when %%s impacted :toLower. I thought I remembered doing an experiment that showed loss of access to FOR variables after a call, but it wasn't quite crystallizing in my mind. Your simple test code makes the behavior very clear.

jeb wrote:the main problem in the "old" implementation is the

Code: Select all

call set %~1=%%%~1:%%~a%%
It is very slow
I'm assuming the slowness is inherent to the CALL statement. I'm aware a CALL to a label slows down as the size of the file increases. But I am surprised that a call without a label is so slow. Can you shed any light on the mechanism behind the scenes that is making CALL so slow. I am also seeing a high degree of variability between machines.

Dave Benham

Post Reply