3 SCOPE AND DELAYED EXPANSION

In the prior chapter, you learned about variables, how to set them, and how to resolve their values. In this chapter, I’ll focus on the setlocal command, which is central to some significant and disparate features of Batch and alters when, where, and how you can handle variables. First, it defines scope: where and when those variables can be accessed and manipulated. Second, it enables a feature called delayed expansion, which alters how variables are resolved, one upshot of which allows you to store one variable inside another variable.

All languages handle scope in some fashion, but delayed expansion, or something ...

Get The Book of Batch Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.