Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 68,792 of 68,980    |
|    Anton Shepelev to All    |
|    Re: ENDLOACAL & CALL ... fails to expand    |
|    16 May 24 01:44:30    |
      From: anton.txt@gmail.moc              R.Wieser to Anton Shepelev:              > > @ECHO OFF       > > SETLOCAL       > > SET VAL=1       > > SET REF=VAL       > > ENDLOCAL & CALL ECHO REF points to: [%%%REF%%%]       > >       > > Why can't REF be expanded on the last line as in the       > > first example?       >       > Because the "call echo" is used to perform a delayed       > expansion. After the "call" is evaluated, the line       > becomes:       >       > ENDLOCAL & ECHO REF points to: [%VAL%]              I think the acutual sequece is a tad different. First,       percent expantion turns the original line into:              ENDLOCAL & CALL ECHO REF points to: [%VAL%]              Then ENDLOCAL is executed and the local value of VAL is       lost. And finally, %VAL% is evaluated as an empty string.              > But after ENDLOCAL is executed, VAL is no longer defined.       > If you define VAL outside the SETLOCAL, you get this       > value:              Yes, I have observed this in my experiments. Thanks you.              --       () ascii ribbon campaign -- against html e-mail       /\ www.asciiribbon.org -- against proprietary attachments              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca