AAA: For realists.
dabean
@dabean
Best posts made by dabean
-
RE: I hate cmd.exe
@aogail said:
@dabean said:
It's not exactly a full-fledged programming language.
That's a pretty poor excuse for failing to read the correct value of a variable inside an if block. ;P
Sorry, didn't read the question properly. Set /? provides explanation:
Finally, support for delayed environment variable expansion has been
added. This support is always disabled by default, but may be
enabled/disabled via the /V command line switch to CMD.EXE. See CMD /?
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in () do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in () do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows you to use a different
character (the exclamation mark) to expand environment variables at
execution time. If delayed variable expansion is enabled, the above
examples could be written as follows to work as intended:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)
set LIST=
for %i in (*) do set LIST=!LIST! %i
echo %LIST% -
RE: Mashup Challenge $100,000 prize - WTF if Spectate Swamp wins?
@AbbydonKrafts said:
Your "WC" might accidentally eat that tape!
I should think a medicine bird would be able to medicate itself.
Latest posts made by dabean
-
RE: SF addict
This made me wonder how they handle possessive case in the Stargate novels.
-
RE: Subway
An inch is pushing it, at most I'd use about half that. Too much filling and it either spills out the front when you close it or the cheese oozes out the sides while it's cooking.
I've never tried PBJ's, or anything sweet in mine. Hmm, sounds interesting.
-
RE: Who cares what they call it.
"Rag szám" translates to "suffix number". "Rag" on its own translates to "affix".
-
RE: Throwing stuff
I have one of those really bouncy red rubber balls that I throw against the wall from time to time. It takes just enough concentration to let me start thinking laterally when I'm stuck with something (that's my theory anyway). I don't share an office though.
-
RE: Boss keeps bringing in his home pc and asking the IT staff to fix it.
I happen to agree with tster. It's his choice to have the company and employ you, just as it's your choice to work there. No guns to anybody's heads, just a free market with people willing to step in where required.
-
RE: Not Always Right
I realised most other people don't think that way while I was learning to write. I accidentally wrote '3' instead of 'b' one day, and when asked why I replied "they're both green".
After that I kept things like that to myself.