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 3785598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:33:10+00:00 2026-05-19T11:33:10+00:00

Okay guys, let my try to explain my problem: I start with a line

  • 0

Okay guys, let my try to explain my problem:

I start with a line from where I start 2 different functions

setlocal EnableDelayedExpansion
for %%i in ("C:\*.*") do (
call :function1 "%%~i"
call :function2 "%%~i"
)
goto :eof

In function1, at a certain point I DO a SET in a local environment:

setlocal EnableDelayedExpansion
...
...
set name1=blabla
endlocal  & SET name=%name1%
echo %name%
goto :eof

The echo does return my variable. Now onto my problem.
I quit function one and i go to function 2 (see first code-segment)
I can’t call the variable form here. I tried in the function2, I tried before function2 is called, but both didn’t resolve the issue.

My guess is a have set only a local variable for function1. I search the nets but i read that the line “endlocal & SET name=%name1%” should have solved my issue.

I hope I have explained it well, all help appreciated!

  • 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-05-19T11:33:11+00:00Added an answer on May 19, 2026 at 11:33 am

    I’m not sure where your problem lies since this works perfectly:

    @setlocal enableextensions enabledelayedexpansion
    @echo off
    set name=ORIGNAME
    for %%i in (1 2) do (
        call :function1 %%i
        echo in main %name% !name!
    )
    endlocal
    goto :eof
    
    :function1:
        setlocal enableextensions enabledelayedexpansion
        set name1=%1_blabla
        endlocal  & SET name=%name1%
        echo in function %name%
        goto :eof
    

    outputting:

    in function 1_blabla
    in main ORIGNAME 1_blabla
    in function 2_blabla
    in main ORIGNAME 2_blabla
    

    Are you certain that, when you used name in the main areas, you used !name! instead of %name%?

    If you used the %name% variant, that would be evaluated when the entire for loop was read, not at the time when you used it (in other words, it would be blank). You can see that in the output of ORIGNAME in the main line.

    I’m not certain that’s the case since you are using delayed expansion. But, just in case, I thought I’d mention it. I always use delayed expansion and I always used the ! variants of the environment variables since it more closely matches how I expect a shell to work.

    In any case, the code I’ve given works fine so you may want to fiddle with that to see if you can incorporate it into your own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, since none of you guys like my question, let me rephrase it. User
Okay guys! Right now, I am using Descending for my data because i want
Okay guys, I have read through all the other posts and question on jQuery
Okay, before you guys go nuts -- this is just a small site, temporary
Okay, some Guys will know what i mean and edit my Question but they
Okay, I'll be straight with you guys: I'm not sure exactly how Domain Driven
Okay, I have a feeling that you guys'll be able to quickly point out
Okay guys, I'm sure this has a very simple solution but my searches are
Okay I have been racking my brain trying to build a JSON array from
Okay, I've looked all over the internet for a good solution to get PHP

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.