Batch Processing Learning Post ① —— Detailed Analysis of Variable Expansion and the "Variable Delay" Principle of the call Command
Preface:
This series of tutorials is suitable for students with a certain batch processing foundation. If you don't understand the content below, it means your foundation is relatively poor. It is recommended that you lurk in the forum for a period of time, read old posts and practice carefully. After coming back, you will definitely understand.
Now let's systematically learn about variable expansion in batch processing and the "variable delay" of the call command.
Note: Unless otherwise specified, the content explained in the batch processing learning post is all in the batch processing environment.
I. Variable Expansion
How does variable expansion work?
Please execute Code 1 first.
1. Variable Expansion
(1) When cmd reads a variable statement using "%" for reference, it first checks whether the number of "%" on the left of "var" is odd. If it is odd, it replaces "%var%" with the value of the variable. If it is even, it does not replace it. If the variable is not defined, it is replaced with an empty string.
2. Remove Percent Signs
(1) After "%var%" is replaced with the value of the variable, the percent signs on both sides will naturally be reduced by one.
(2) If the number of percent signs on one side is even, then half of the percent signs are directly removed. If the number of percent signs on one side is odd, then (the number of percent signs + 1) ÷ 2 percent signs are removed. If there are no percent signs, no removal is done.
Let's analyze the last line of code in Code 1 (echo.%%%var%%%%) for students.
(1) Variable Expansion: Because there are three percent signs on the left of "var", and 3 is odd, so "%var%" is replaced with "test". Then "%%%var%%%%" becomes "%%test%%%".
(2) Remove Percent Signs: Because there are two percent signs on the left of "test", so half are removed directly. And there are three percent signs on the right, so (3 ÷ 2 + 0.5) 2 percent signs are removed. So the final result becomes "%test%".
The description in "Replacement Steps of Variable Expansion" may be a bit abstract, but everyone should understand it after practicing and combining with the analysis of "(echo.%%%var%%%%)".
At this point, students should be able to understand the process of environment variable expansion. But one thing must be made clear to students. The above-mentioned "replacement steps" are just to help new students better understand the process of environment variable expansion. In batch processing, the command interpreter does not follow the above rules to expand variables. But students don't need to worry. Although the processing method is different, the result is the same.
Next, we will explain the process of variable expansion from the perspective of the command interpreter interpreting "%" and "variable identifier".
The "%" character is interpreted as a "variable identifier" in batch processing. So in batch processing, "%" belongs to a special symbol. From the perspective of preprocessing, after the command interpreter reads a complete batch processing statement ("%var%"), it first expands the variable. At this time, all "%" in the statement are interpreted as "variable identifiers". After variable expansion is completed, all "%" no longer exist. However, at this time, the command interpreter has not yet parsed the escape character "^". So how to output "%"? We just want to output "%var%" and not let it be interpreted. Then we need to find a way to cancel the special nature of "%", so that the command interpreter does not process it. At this time, the character that is needed to escape "%" is actually "% " itself. So the second identity of the "%" character in batch processing is the "escape character". Note: "%" only escapes "%", which is different from "^".
Let's still analyze "echo.%%%var%%%%" in Code 1.
1. The first "%" after echo. escapes the second "%", at this time the second "%" becomes a normal character, and the command interpreter no longer interprets it. The first "%" is interpreted as an "escape character" by the command interpreter, so it does not exist.
2. The third "%" after echo. and var and the fourth "%" form a complete variable reference, so "var" is replaced with "test". The two "%" used to reference "var" are interpreted as "variable identifiers" by the command interpreter, so they do not exist.
3. Similarly to , the fifth "%" after echo. escapes the sixth "%", at this time the sixth "%" becomes a normal character, and the command interpreter no longer interprets it. At this time, the fifth "%" does not exist.
4. The last, that is, the seventh "%", the command interpreter interprets it as a "variable identifier", so it does not exist.
5. At this time, all processing of "%" is completed. We combine the results of the first four steps, %, test, %, and the final result becomes: %test%.
According to the above analysis process, it can be seen that when two "%" are together, the previous "%" is interpreted as an "escape character" by the command interpreter, and the latter "%" is escaped into a normal character by the previous "%", and follows the principle from left to right.
I don't know if the above explanation can be understood by everyone. Even if it is not understood, it doesn't matter. As long as the content in "Replacement Steps of Variable Expansion" can be understood, because the content in "Replacement Steps of Variable Expansion" is easier to understand. So in the following text and subsequent learning posts, "replacement steps" are still used for explanation.
The steps in "Replacement Steps of Variable Expansion" are laws summarized according to the results of variable expansion, which are easier for new students to understand. But to understand the reason essentially, it is still necessary to understand the above analysis, otherwise you will ask why odd numbers are expanded and even numbers are not expanded, hehe.
Note: Due to the dual characteristics of "%", some "%" naturally do not exist after preprocessing, so some people also call it an "escape character" or "carat".
"Original article, please indicate the source cn-dos&q8249014 when reposting."
II. "Variable Delay" of the call Command
We know that before a command is executed, the command interpreter will perform some necessary interpretation and processing on the command statement. This process is called the "preprocessing work". The "variable expansion" mentioned in the first paragraph is part of the preprocessing work. Let's first look at some knowledge related to preprocessing.
__________________________________________________________________________
Here, I will briefly explain to students what "preprocessing work" is.
In my personal understanding, preprocessing is a process in which the command interpreter interprets and matches commands, which is performed before the command is executed.
So what exactly does "preprocessing work" do?
(1) First, expand the variables referenced using "%".
(2) Match and interpret the characters in the command, such as matching "&" as a command connector.
Rem (3) If there is an if (for) command, check the format of the if (for) command.
Rem (4) If there is an if (for) command, after all variables in the if (for) command statement are expanded, perform conditional processing, and then submit the command statement that meets the conditions to the command main body for execution.
(3) ……Waiting for your exploration.
(4) Perform delayed variable expansion (will process the escape character "^").
(5) After the preprocessing work is completed, submit the command statement to the command main body for execution.
Note: The content commented with Rem above does not require new students to fully understand. Friends with rich batch processing experience should be able to understand.__________________________________________________________________________
In order to help students better understand the following two codes, an article by willsort in this forum is quoted.
Please execute Code 2 first.
Why is the result of Code 2 executed "test" instead of "cn-dos"?
Analysis:
________________________________________________________________________
This is because after cmd reads the complete for statement, it performs necessary preprocessing work, and all variables that can be expanded have been replaced with the values set before. So when executing "echo.%var%" in Code 2, the actual command executed is "echo.test".
(In other words, before executing "set "var=cn-dos", "%var%" is equal to "test".)
________________________________________________________________________
Please execute Code 3 first.
What is the difference between variable expansion with and without using the call command? (test&cn-dos)
Code 3 only has one more call. Why is the result different from Code 2? Why can Code 3 display "cn-dos"?
How does the call command realize the "variable delay" effect?
Analysis:
_______________________________________________________________________________
Because the call command also defaults to expanding variables when processing the command statement, so after using the call command, there will be one more "replacement step".
(1): When reading a complete statement, the steps of the command interpreter expanding environment variables during preprocessing.
1. Variable Expansion: "call echo.%%var%%", because there are two percent signs on the left of "var", so the variable is not replaced.
2. Remove Percent Signs: Because the percent signs on both sides of "var" are even numbers, so half of the percent signs on both sides are removed and become "%var%".
(2): After the command statement is submitted to the call command, the steps of the call command expanding environment variables internally.
1. Variable Expansion: At this time, "set "var=cn-dos"" has been executed, and the value of var has been defined as "cn-dos", so "%var%" will be expanded to "cn-dos".
2. Remove Percent Signs: There are no percent signs, so no removal is done. So the result is "cn-dos".
Note: The above "replacement steps" are the same as the "(Replacement Steps of Variable Expansion)" in the first paragraph.
_______________________________________________________________________________
The main idea of using call to perform variable delay expansion above is:
(1) Use an even number of percent signs on the left of the variable to reference the variable, so that the variable is not expanded during preprocessing.
(2) After the command statement is submitted to the call command, the call command will expand the variable again when processing the command statement, so as to achieve the purpose of delayed expansion.
Here, new students are requested to compare the results of Code 2 and 3 in combination with the above analysis and understand the reason, and experience the application of the "variable delay" of the call command. This will help the learning of the third paragraph of the example demonstration.
"Original article, please indicate the source cn-dos&q8249014 when reposting."
III. Example Demonstration
Code 4 is a code for converting decimal to hexadecimal written by "terse" in the forum. Code 5 is a code "trimmed" by me.
This code is also the shortest code for converting decimal to hexadecimal that I have seen.
In Code 4, the variable interception part cannot directly use "set h=!hx:~!n!,1!!h!" or "set h=%hx:~!n!,1%!h!" for interception. So he uses for to pass the variable "!n!" to %%i, and then performs variable replacement "set h=!hx:~%%i,1!!h!".
In the "trimmed" Code 5 of mine, the "variable delay" of the call command is fully utilized, that is: "call set h=%%hx:~!n!,1%%!h!".
Here, only the batch processing skills are discussed, and there is no other meaning. The code of "terse" is still very good, hehe.
Compare Code 4 and 5 above, and experience the application of call "variable delay" again. It is best to fully understand the meaning of each sentence of the code.
Homework: Understand why the value of "str" in "echo.%str% 的十六进制为:0x!h!" in Code 5 is the number you entered instead of 0.
Analyze the execution process of "call set h=%%hx:~!n!,1%%!h!" by yourself.
IV. Summary
Here, some supplements are made for students on the "replacement steps" of variables referenced using "!" after enabling delayed environment variables.
(1) After reading the command statement, cmd will not immediately expand the variable referenced using "!", and the variable referenced using "%" still uses the rules in the first paragraph "(Replacement Steps of Variable Expansion)" for expansion.
(2) Perform preprocessing matching work
(3) Expand the variable referenced using "!" before the command is executed . That is to say, after enabling variable delay, the variable referenced using "!" will be expanded in the last step before executing the sentence after reading the sentence. The expansion rule is: first check whether the variable is defined, if it is, expand it to its value, otherwise replace it with an empty string. In addition, all excess "!" will be replaced with an empty string (interpreted as a "variable identifier"). If it is executed in the cmd command line, the excess "!" will not be replaced.
The difference between variable expansion referenced by "%" and "!":
After reading a single statement or a compound statement, all variables referenced using "%" in the statement will be expanded.
After reading a single statement or a compound statement, all variables referenced using "!" in the statement will not be expanded, but will be expanded in the last step before executing the sentence after reading the sentence.
The above-mentioned "variable expansion" is actually the consciousness of "variable replacement", which may be easier for students to understand.
Well, this lesson ends here.
If there are any improper places in the text, please correct them by forum friends.
"Original article, please indicate the source cn-dos&q8249014 when reposting."
Revised on December 1, 2009
[ Last edited by q8249014 on 2010-2-4 at 16:52 ]
Preface:
This series of tutorials is suitable for students with a certain batch processing foundation. If you don't understand the content below, it means your foundation is relatively poor. It is recommended that you lurk in the forum for a period of time, read old posts and practice carefully. After coming back, you will definitely understand.
Now let's systematically learn about variable expansion in batch processing and the "variable delay" of the call command.
Note: Unless otherwise specified, the content explained in the batch processing learning post is all in the batch processing environment.
I. Variable Expansion
How does variable expansion work?
@echo off
:: Code 1
set "var=test"
echo.%var%
echo.%%var%
echo.%%var%%
echo.%%%var%%%
echo.%%%var%%%%
pause
test
%var
%var%
%test%
%test%
Press any key to continue...
Please execute Code 1 first.
1. Variable Expansion
(1) When cmd reads a variable statement using "%" for reference, it first checks whether the number of "%" on the left of "var" is odd. If it is odd, it replaces "%var%" with the value of the variable. If it is even, it does not replace it. If the variable is not defined, it is replaced with an empty string.
2. Remove Percent Signs
(1) After "%var%" is replaced with the value of the variable, the percent signs on both sides will naturally be reduced by one.
(2) If the number of percent signs on one side is even, then half of the percent signs are directly removed. If the number of percent signs on one side is odd, then (the number of percent signs + 1) ÷ 2 percent signs are removed. If there are no percent signs, no removal is done.
Let's analyze the last line of code in Code 1 (echo.%%%var%%%%) for students.
(1) Variable Expansion: Because there are three percent signs on the left of "var", and 3 is odd, so "%var%" is replaced with "test". Then "%%%var%%%%" becomes "%%test%%%".
(2) Remove Percent Signs: Because there are two percent signs on the left of "test", so half are removed directly. And there are three percent signs on the right, so (3 ÷ 2 + 0.5) 2 percent signs are removed. So the final result becomes "%test%".
The description in "Replacement Steps of Variable Expansion" may be a bit abstract, but everyone should understand it after practicing and combining with the analysis of "(echo.%%%var%%%%)".
At this point, students should be able to understand the process of environment variable expansion. But one thing must be made clear to students. The above-mentioned "replacement steps" are just to help new students better understand the process of environment variable expansion. In batch processing, the command interpreter does not follow the above rules to expand variables. But students don't need to worry. Although the processing method is different, the result is the same.
Next, we will explain the process of variable expansion from the perspective of the command interpreter interpreting "%" and "variable identifier".
The "%" character is interpreted as a "variable identifier" in batch processing. So in batch processing, "%" belongs to a special symbol. From the perspective of preprocessing, after the command interpreter reads a complete batch processing statement ("%var%"), it first expands the variable. At this time, all "%" in the statement are interpreted as "variable identifiers". After variable expansion is completed, all "%" no longer exist. However, at this time, the command interpreter has not yet parsed the escape character "^". So how to output "%"? We just want to output "%var%" and not let it be interpreted. Then we need to find a way to cancel the special nature of "%", so that the command interpreter does not process it. At this time, the character that is needed to escape "%" is actually "% " itself. So the second identity of the "%" character in batch processing is the "escape character". Note: "%" only escapes "%", which is different from "^".
Let's still analyze "echo.%%%var%%%%" in Code 1.
1. The first "%" after echo. escapes the second "%", at this time the second "%" becomes a normal character, and the command interpreter no longer interprets it. The first "%" is interpreted as an "escape character" by the command interpreter, so it does not exist.
2. The third "%" after echo. and var and the fourth "%" form a complete variable reference, so "var" is replaced with "test". The two "%" used to reference "var" are interpreted as "variable identifiers" by the command interpreter, so they do not exist.
3. Similarly to , the fifth "%" after echo. escapes the sixth "%", at this time the sixth "%" becomes a normal character, and the command interpreter no longer interprets it. At this time, the fifth "%" does not exist.
4. The last, that is, the seventh "%", the command interpreter interprets it as a "variable identifier", so it does not exist.
5. At this time, all processing of "%" is completed. We combine the results of the first four steps, %, test, %, and the final result becomes: %test%.
According to the above analysis process, it can be seen that when two "%" are together, the previous "%" is interpreted as an "escape character" by the command interpreter, and the latter "%" is escaped into a normal character by the previous "%", and follows the principle from left to right.
I don't know if the above explanation can be understood by everyone. Even if it is not understood, it doesn't matter. As long as the content in "Replacement Steps of Variable Expansion" can be understood, because the content in "Replacement Steps of Variable Expansion" is easier to understand. So in the following text and subsequent learning posts, "replacement steps" are still used for explanation.
The steps in "Replacement Steps of Variable Expansion" are laws summarized according to the results of variable expansion, which are easier for new students to understand. But to understand the reason essentially, it is still necessary to understand the above analysis, otherwise you will ask why odd numbers are expanded and even numbers are not expanded, hehe.
Note: Due to the dual characteristics of "%", some "%" naturally do not exist after preprocessing, so some people also call it an "escape character" or "carat".
"Original article, please indicate the source cn-dos&q8249014 when reposting."
II. "Variable Delay" of the call Command
We know that before a command is executed, the command interpreter will perform some necessary interpretation and processing on the command statement. This process is called the "preprocessing work". The "variable expansion" mentioned in the first paragraph is part of the preprocessing work. Let's first look at some knowledge related to preprocessing.
__________________________________________________________________________
Here, I will briefly explain to students what "preprocessing work" is.
In my personal understanding, preprocessing is a process in which the command interpreter interprets and matches commands, which is performed before the command is executed.
So what exactly does "preprocessing work" do?
(1) First, expand the variables referenced using "%".
(2) Match and interpret the characters in the command, such as matching "&" as a command connector.
Rem (3) If there is an if (for) command, check the format of the if (for) command.
Rem (4) If there is an if (for) command, after all variables in the if (for) command statement are expanded, perform conditional processing, and then submit the command statement that meets the conditions to the command main body for execution.
(3) ……Waiting for your exploration.
(4) Perform delayed variable expansion (will process the escape character "^").
(5) After the preprocessing work is completed, submit the command statement to the command main body for execution.
Note: The content commented with Rem above does not require new students to fully understand. Friends with rich batch processing experience should be able to understand.__________________________________________________________________________
In order to help students better understand the following two codes, an article by willsort in this forum is quoted.
Only some supplementary modifications have been made in the text to make the explanation more accurate and convenient for everyone to refer to
Regarding environment variable delay expansion, you can check some instructions using set /?. However, considering its crude translation level, it is recommended to first switch to English display status using chcp 437 before viewing. Since the text has been explained very comprehensively and there are several code examples, it should not be difficult to understand. Only some supplements are made here.
In many visible official documents, a pair of percent signs is used to close the environment variable to complete the replacement of its value. This process is called "expansion", which is actually a first-party concept, referred to from the perspective of the command interpreter. From the perspective of us users, it can be regarded as reference, call or get.
The process of the command interpreter expanding environment variables is roughly as follows: First, read a complete statement of the command line. (Before the command is interpreted and executed, some preprocessing work will be performed.) Then, match the string closed by percent signs. If a matching environment variable is found in the environment space, its value is used to replace the original string and the percent signs themselves. If no match is obtained, an empty string is used to replace it. This process is the "expansion" of the environment variable, which belongs to the preprocessing category of the command line.
A "complete statement" is interpreted by the NT command interpreter CMD as statements containing statement blocks such as "for, if else, ()" and compound statements connected by "&, |, &&, ||" and other connections.
Therefore, when CMD reads a for statement, all statements closed by a pair of parentheses will be read together and necessary preprocessing work will be completed, which includes the expansion of environment variables. Therefore, before all statements in for are executed, all environment variables have been replaced with the values set before for, thus becoming a string constant, and no longer a variable. No matter how those environment variables are modified in for, only the environment variable space is actually affected, not the inside of the for statement.
In order to be able to perceive the dynamic changes of environment variables inside the for statement, CMD designs the feature of delayed environment variable expansion. And in order to distinguish from environment variables closed by percent signs for expansion, after enabling delayed environment variable expansion, to expand the variable delay, English exclamation marks should be used to close the environment variable. That is to say, after CMD reads a complete statement, it will not immediately expand the environment variable closed by English exclamation marks, but will expand it again before executing a certain single statement, that is, this expansion behavior is "delayed". But the environment variable closed by percent signs will still be expanded immediately after reading a complete statement.
The delayed environment variable expansion feature is off by default in CMD. The methods to enable it are currently two: one is CMD /v:on, which will open a new command line shell. Before using exit to exit this shell, the delayed expansion feature is always effective, and it is often used in the command line environment; the other is setlocal EnableDelayedExpansion, which will limit the modification of environment variables to the local space. After endlocal, the delayed expansion feature and the previous modifications to environment variables will disappear together, and it is often used in batch processing statements.
@echo off
:: Code 2
set "var=test"
for /l %%i in (1 1 1) do (
set "var=cn-dos"
echo.%var%
)
pause
test
Press any key to continue...
Please execute Code 2 first.
Why is the result of Code 2 executed "test" instead of "cn-dos"?
Analysis:
________________________________________________________________________
This is because after cmd reads the complete for statement, it performs necessary preprocessing work, and all variables that can be expanded have been replaced with the values set before. So when executing "echo.%var%" in Code 2, the actual command executed is "echo.test".
(In other words, before executing "set "var=cn-dos", "%var%" is equal to "test".)
________________________________________________________________________
@echo off
:: Code 3
set "var=test"
for /l %%i in (1 1 1) do (
set "var=cn-dos"
call echo.%%var%%
)
pause
cn-dos
Press any key to continue...
Please execute Code 3 first.
What is the difference between variable expansion with and without using the call command? (test&cn-dos)
Code 3 only has one more call. Why is the result different from Code 2? Why can Code 3 display "cn-dos"?
How does the call command realize the "variable delay" effect?
Analysis:
_______________________________________________________________________________
Because the call command also defaults to expanding variables when processing the command statement, so after using the call command, there will be one more "replacement step".
(1): When reading a complete statement, the steps of the command interpreter expanding environment variables during preprocessing.
1. Variable Expansion: "call echo.%%var%%", because there are two percent signs on the left of "var", so the variable is not replaced.
2. Remove Percent Signs: Because the percent signs on both sides of "var" are even numbers, so half of the percent signs on both sides are removed and become "%var%".
(2): After the command statement is submitted to the call command, the steps of the call command expanding environment variables internally.
1. Variable Expansion: At this time, "set "var=cn-dos"" has been executed, and the value of var has been defined as "cn-dos", so "%var%" will be expanded to "cn-dos".
2. Remove Percent Signs: There are no percent signs, so no removal is done. So the result is "cn-dos".
Note: The above "replacement steps" are the same as the "(Replacement Steps of Variable Expansion)" in the first paragraph.
_______________________________________________________________________________
The main idea of using call to perform variable delay expansion above is:
(1) Use an even number of percent signs on the left of the variable to reference the variable, so that the variable is not expanded during preprocessing.
(2) After the command statement is submitted to the call command, the call command will expand the variable again when processing the command statement, so as to achieve the purpose of delayed expansion.
Here, new students are requested to compare the results of Code 2 and 3 in combination with the above analysis and understand the reason, and experience the application of the "variable delay" of the call command. This will help the learning of the third paragraph of the example demonstration.
"Original article, please indicate the source cn-dos&q8249014 when reposting."
III. Example Demonstration
Code 4 is a code for converting decimal to hexadecimal written by "terse" in the forum. Code 5 is a code "trimmed" by me.
This code is also the shortest code for converting decimal to hexadecimal that I have seen.
@echo off&setlocal enabledelayedexpansion
:: Code 4
:: Code by CN-DOS terse
set "hx=0123456789ABCDEF"
for /l %%a in (1 1 10000) do (
set /a str=%%a
for /l %%i in (1 1 8) do (
if !str! gtr 0 (
set/a "n=str&15,str>>=4"
for %%i in (!n!) do set h=!hx:~%%i,1!!h!
))
echo %%a 的十六进制为:0x!h!&set "h="
)
pause
@echo off&setlocal enabledelayedexpansion
:: Code 5
:: Code by CN-DOS terse
set "hx=0123456789ABCDEF"
set/p str=:
(for /l %%i in (1 1 8) do (
if !str! GTR 0 (
set/a "n=str&15,str>>=4"
call set h=%%hx:~!n!,1%%!h!
)
)
if not defined h set "h=0"
echo.%str% 的十六进制为:0x!h!)
pause
In Code 4, the variable interception part cannot directly use "set h=!hx:~!n!,1!!h!" or "set h=%hx:~!n!,1%!h!" for interception. So he uses for to pass the variable "!n!" to %%i, and then performs variable replacement "set h=!hx:~%%i,1!!h!".
In the "trimmed" Code 5 of mine, the "variable delay" of the call command is fully utilized, that is: "call set h=%%hx:~!n!,1%%!h!".
Here, only the batch processing skills are discussed, and there is no other meaning. The code of "terse" is still very good, hehe.
Compare Code 4 and 5 above, and experience the application of call "variable delay" again. It is best to fully understand the meaning of each sentence of the code.
Homework: Understand why the value of "str" in "echo.%str% 的十六进制为:0x!h!" in Code 5 is the number you entered instead of 0.
Analyze the execution process of "call set h=%%hx:~!n!,1%%!h!" by yourself.
IV. Summary
Here, some supplements are made for students on the "replacement steps" of variables referenced using "!" after enabling delayed environment variables.
(1) After reading the command statement, cmd will not immediately expand the variable referenced using "!", and the variable referenced using "%" still uses the rules in the first paragraph "(Replacement Steps of Variable Expansion)" for expansion.
(2) Perform preprocessing matching work
(3) Expand the variable referenced using "!" before the command is executed . That is to say, after enabling variable delay, the variable referenced using "!" will be expanded in the last step before executing the sentence after reading the sentence. The expansion rule is: first check whether the variable is defined, if it is, expand it to its value, otherwise replace it with an empty string. In addition, all excess "!" will be replaced with an empty string (interpreted as a "variable identifier"). If it is executed in the cmd command line, the excess "!" will not be replaced.
The difference between variable expansion referenced by "%" and "!":
After reading a single statement or a compound statement, all variables referenced using "%" in the statement will be expanded.
After reading a single statement or a compound statement, all variables referenced using "!" in the statement will not be expanded, but will be expanded in the last step before executing the sentence after reading the sentence.
The above-mentioned "variable expansion" is actually the consciousness of "variable replacement", which may be easier for students to understand.
Well, this lesson ends here.
If there are any improper places in the text, please correct them by forum friends.
"Original article, please indicate the source cn-dos&q8249014 when reposting."
Revised on December 1, 2009
[ Last edited by q8249014 on 2010-2-4 at 16:52 ]

