China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 02:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Question about dynamic environment variables View 744 Replies 2
Original Poster Posted 2008-06-09 01:55 ·  中国 山东 淄博 联通
银牌会员
★★★
Credits 1,604
Posts 646
Joined 2008-04-13 23:39
18-year member
UID 115804
Gender Male
Status Offline
When I was bored, I tested a short piece of code. Like this...

@echo off&setlocal enabledelayedexpansion
echo %time%
set time=a&echo !time!
pause
echo %time%
echo %time%
echo %time%
pause


Changing time to random gives the same result. Aren't system variables like these all dynamically calculated in real time~? Why is it that after assigning a value manually, it no longer changes in real time?
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
Floor 2 Posted 2008-06-18 18:08 ·  中国 北京 联通
银牌会员
★★★
Credits 1,287
Posts 634
Joined 2007-05-02 15:06
19-year member
UID 87277
Gender Male
From cmd.exe
Status Offline
In the set /? help there is:

If the user explicitly defines a variable with one of these names, then
that definition will override the dynamic one described below:
Floor 3 Posted 2008-06-18 21:51 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
If you've learned C, it should be fairly easy to understand. You can think of it as a local variable overriding a global variable.
Forum Jump: