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-03 22:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Looking for an old thread with a very detailed explanation of set! View 811 Replies 2
Original Poster Posted 2007-03-25 12:34 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
I think the poster was lxmxn?
It analyzed set substring extraction by position in great detail. I forget whether it used %time% or %date% or a string as the example!
The rough content was like this:
set=1234567890
Take the first character 1, the second 2, the third 3, and so on...
I think it also talked about replacing content...
Now I can't find that thread anywhere
Floor 2 Posted 2007-03-25 12:39 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
set /? seems to have it


Environment variable substitution has been enhanced as follows:

%PATH:str1=str2%

This expands the PATH environment variable, replacing each occurrence of "str1"
in the expanded result with "str2".
To effectively delete all occurrences of "str1" from the expanded result, "str2"
can be empty.
"str1" can begin with an asterisk; in that case, everything from the
beginning of the expanded result up to the first occurrence of the remainder
of str1 is kept matched.

You can also specify substrings for the expansion.



%PATH:~10,5%

This expands the PATH environment variable, then uses only the five characters
starting with the 11th character (offset 10) in the expanded result. If length
is not specified, the default value is the remainder of the variable value. If
both numbers (offset and length) are negative, the numbers used are the length
of the environment variable value plus the specified offset or length.

%PATH:~-10%

This extracts the last ten characters of the PATH variable.

%PATH:~0,-2%

This extracts all characters of the PATH variable except the last two.
Floor 3 Posted 2007-03-25 13:24 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Forum Jump: