Why letter A is not printed?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Irv
Posts: 2
Joined: 05 Oct 2017 23:37

Why letter A is not printed?

#1 Post by Irv » 05 Oct 2017 23:43

Hi folks,

I would expect the following script to print the letter A.

Why it does not print the letter A?

with best regards,
Irv

Code: Select all

for %%f in (A B C) do (
  echo %%f
  set V=%%f
  echo V: %V% "<- i would expect, that the letter A is printed. why not?"
  pause
)


This is the output:

Code: Select all

A
Now printing a letter:  "<- i would expect, that the letter A is printed. why not?"


Code: Select all

 INFO.BAT version 1.4
--------------------------------------------------------------------------------
Windows version        :  Microsoft Windows [Version 10.0.15063]
Product name           :  Windows 10 Home, 64 bit
Performance indicators :  Processor Cores: 4      Visible RAM: 4119664 kilobytes

Date/Time format       :  (dd/mm/yy)  06.10.2017   7:34:41,87
__APPDIR__             :  C:\WINDOWS\system32\
ComSpec                :  C:\WINDOWS\system32\cmd.exe
PathExt                :  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions             :  system: Enabled   user: Enabled
Delayed expansion      :  system: Disabled  user: Disabled
Locale name            :  de-AT       Code Pages: OEM  850    ANSI 1252
DIR  format            :  03.10.2017  20:55       939 524 096 pagefile.sys
Permissions            :  Elevated Admin=No, Admin group=Yes

                          Missing from the tool collection:  debug

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Why letter A is not printed?

#2 Post by Squashman » 06 Oct 2017 07:17

You need to use Delayed Expansion.

Irv
Posts: 2
Joined: 05 Oct 2017 23:37

Re: Why letter A is not printed?

#3 Post by Irv » 06 Oct 2017 21:54

Thank you very much. Now, it works.

Post Reply