Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7924153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:35:58+00:00 2026-06-03T17:35:58+00:00

I am trying to do this in a DOS CMD Script: @setlocal @for /L

  • 0

I am trying to do this in a DOS CMD Script:

@setlocal
@for /L %%X in (1,1,10) do @call :label1 %%X
@endlocal
@exit /b

:label1
@set I=%1
@set /P A%I%=SET A%I% to?
@echo You entered %%A%%I%%
exit /b

However I cannot get it to echo the actual entered value. I have tried all variations on the echo line.

Can anyone tell me what I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:36:12+00:00Added an answer on June 3, 2026 at 5:36 pm

    To get your output, you could use call echo You entered %%A%I%%%.

    But it would be better to use delayed expansion so that special characters like & and | can never cause you problems: echo You entered !A%I%!

    In order to use delayed expansion, you need to enable it with setlocal enableDelayedExpansion.

    Helpful hint 1 – Put @echo off at the top of your script. Then you never need to use @ in any of the following commands.

    Helpful hint 2 – You should explicitly clear any existing variable value prior to using SET /P. You can’t be sure it is not already defined. If the user simply presses <Enter> without entering anything, then the existing value will be preserved.

    Helpful hint 3 – You don’t even need the I variable. You can simply use the %1 parameter wherever you have %I%.

    Helpful hint 4 – Better yet, you don’t even need to call a subroutine.

    @echo off
    setlocal enableDelayedExpansion
    for /L %%X in (1,1,10) do (
      set "A%%X="
      set /P "A%%X=SET A%%X to? "
      echo You entered !A%%X!
    )
    endlocal
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying this for hours, so maybe a fresh set of eyes will
I'm trying to write some dos batch script for manipulating some paths. I haven't
I am trying to set my DOS environment variable in Ruby, and have it
Im trying this, but when i press it it dont changes, it only displays
I'm trying this pattern: (r'^jobs/(?P<job_id>\d+)/$', job_handler) To work with jobs/ and jobs/{job_id}, but the
I'm trying this for almost two hours now, without any luck. I have a
I am trying this code: entLoop:for(var i:*in entities) { for(var i2:*in ignoreEntities) { if(entities[i].type==ignoreEntities[i2])
I'm trying this: {:id => 5, :foos => [1,2,3]}.each {|k,v| v.to_s} But that's returning
i get this error when trying this: ERROR method name expected. How should i
Right now I'm trying this: int a = round(n); where n is a double

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.