What is variable Substitution?
Variable substitution is a feature provided by programming and scripting languages that allows the replacement of variables with values at runtime execution.
For example, in a general scenario, you might have pseudocode that stores variable values and computes the addition of two variables during execution, printing the result to the console.
Below is a pseudocode example for understanding purposes.
first = 1
second = 2
result = first + second
print(second)
In the above example, there are two variables (first and second
) that contain values (1 and 2
). When the code runs, the runtime tool substitutes the variable values (1 and 2), performs the addition (first + second), and prints the result to the console.
Here, the variables are declared for example purposes. In real-time scenarios, variables may hold command-line arguments or settings files that contain dynamic values read at runtime.
Variable substitution is a basic feature provided to enable flexible and dynamic values to be passed at runtime.
Batch Variable Substitution
Batch scripting provides variable substitution that allows to substitues the varlaibe with a value when script is run
@echo off
set msg=welcome to blog
echo Hello, %msg%.
variable declared and assign with a string, During batch script running, the varialble is replaced with value and printed to console