Summary: To separate functions in a batch program, we can use the decisions and "goto" command we learned earlier. Create a variable with two values, e. g. "0" for "do not execute function" and "1" for "do execute this function". The function is created with an if statement testing for that value, and a label to the goto target.
In this video we had a function called "Addition," and to that we had the following code:
::sets function to not execute by default
set add=0
::this is the actual function, or "function body"
:Addition
if %add% == 1 (
::commands go here
set /a answer=%num1% + %num2%
set add=0
)
::to call the function use
set add=1
goto Addition
Mathematical Operators:
"-" Subtraction
"+" Addition
"*" Multiplication
"/" Division
set /a variable=arithmetic + expression