(Some comments were edited out by paultomasi)
Rileyh@paultomasi
When stating about Ed Dyreen, please refrain from being conceited. BTW- Ed Dyreen- expert Paultomasi- not expert
So stating about the way that Ed codes in a conceited manner from your position is not reasonable- you are less experienced than Ed.
Ed Dyreen- expert Paultomasi- not expert
I have no idea how this forum assigns 'Expert' status although I have requested advice on this.
As for me being an expert or not, I think if you navigate yourself over to
http://www.experts-exchange.com (where I spend a lot of my time) you'll be more than satisfied with my credentials as one of the Worlds leading Advanced Batch File programmers with some 22 years of programming experience behind me. I used to go by the name '
t0t0' and at one point last year I was ranked No.2 in the World. At that time, I decided to reap the glory in my real name (
paultomasi) so now I'm currently ranked 12th (due to not being able to port my previous ranking across).
I have only just (6 days ago) started to contribute to this forum so don't be under any illusion about Ed Dyreen being a more capable batch file programmer than myself. You may call
that conceit if you want to.
Before I leave you in Ed Dyreen's 'capable' hands, please take a moment to reflect on the following:
You said:
I did not understand the point of using all the complications: I did not know that they were necessary.
Ed Dyreen's latest offering is:
QUESTION:
What is the difference between "%%~a" and "%%a"?
Could someone answer that?
QUESTION 2:
How can I delimit the !$$! variable by its spaces (if it contains them) in this
Code: Select all
@echo off
echo. question 1:
for %%? in ( "This works" ) do echo.?=%%~?=%%?_
echo. question 2:
set "$var=This works" &for %%? in ( %$var% ) do echo.?=%%?_
pause
exit /b 0
There ya go, simple and unstable, you should be able to understand this not ?
Let's remind ourselves of some key words here:
understand,
necessary,
complications and
simple.
Now let's look at Ed Dyreen's code line-by-line...
This is standard for all batch files. Nothing wrong here!
Absolutely NO NEED for '
echo.' when just '
echo' would have sufficed!
Infact, Ed Dyreen makes a mistake here by inserting a space between '
echo.' and '
question 1:'. This is because unlike just '
echo question 1:' (without the fullstop or period character), DOS actually displays a leading space character in front of '
question 1:'.
Code: Select all
for %%? in ( "This works" ) do echo.?=%%~?=%%?_
Again, absolutely NO NEED for '
echo.' and this time, NO NEED for the trailing underscore ('
_') character either.
The ouptut from this line of code is:
?=This works="This works"_
which means absolutely nothing by itself and which should have infact read:
%%?="This works"
%%~?=This works
Again, absolutely NO NEED for '
echo.' when just '
echo' would have sufficed. And as before, DOS inserts a space character in front of '
question 2:'.
Code: Select all
set "$var=This works" &for %%? in ( %$var% ) do echo.?=%%?_
Firstly, there is absolutely NO NEED to enclose both
Lvalue and
Rvalue of the
SET statement in double-quotes.
Also, there is absolutely NO REASON why '
var' should be preceded with a dollar ('
$') sign. I cannot ever recall seeing Microsoft using this convention in any of their batch file examples. A simple alphanumeric variablename would have sufficed such as just '
var'.
Furthermore, There is absolutely NO NEED to use the ampersand ('
&') character and place two statements onto a single line. The following is much clearer:
set var=This works
for %%? in (%var%) do echo ?=%%?
There is absolutely NO NEED for '
echo.' nor the trailing underscore ('
_') character again.
Not necessary.
Not necessary.
So. Simple? -
NO!
Now let's look at the output from Ed Dyreen's code:
C:\
question 1:
?=This works="This works"_
question 2:
?=This_
?=works_
Press any key to continue . . .
C:\
Not the most aspiring (in my opinion) however, I'll leave you to be the judge of that.