Looking for an example of a sub-function in a batch file?
Sometimes you just want a plain example of a subfunction ergo Sub-Routine in a command prompt batch file to understand how it works!
The CALL command starts a new batch file context along with any parameters specified. When the end of the second batch file is reached or when EXIT is used, control returns immediately after the first CALL statement.
1.) Simple example of a sub-function (sub-routine)!
Here is a simple example in which a sub-function is called twice.
The sub-function multiplies two numbers and outputs the result
Below in the picture you can see: ►► the output
::Call under function 2 times
CALL :sub_function 2 5
CALL :sub_function 5 10
::Waiting for keypress
SET /a result=%1*%2
ECHO %1 mul %2 is %result%
GOTO jumps to a specific point or end of the batch file
Example of subfunction output in a batch file
| (Image-1) Run the example batch and sub-function on MS Windows all OS!
2.) More information about CALL calling sub-functions!
When command extensions are enabled, the CALL command is modified as follows:
The CALL command now accepts markers as jump targets. The syntax is: CALL :marker arguments
Get more help on the CALL command, just practice, because practice makes perfect!
FAQ 140: Updated on: 14 June 2022 06:03
The Windows CMD has internal commands that are in the command prompt itself, this does not start another exe that is started separately The external commands
Sometimes you just want to rename JPEG to JPG to keep things in order, you can do that easily from the command line on MS Windows Desktop and Server OS
The classic search in files for a character string via the command prompt is hardly used anymore, but it is still available on Windows 11, 10, In order
The fastest way to run or start the command prompt in every Windows System, is via RUN-Dialog in Windows 11, 10, and MS Server. Please start via Keyboard-Shortcut
Find Your IP Address Quickly in every Windows OS, the solution is to simple for every User Account on Windows 11, 10, . and MS Server Please start the
The solution is simple to Delete and Overwrite files and folder permanently in Windows 11, 10, and MS Server OS Please feel free and use cipher for
»» My question is not there in the FAQ
Keywords: windows, console, looking, example, subfunction, batch, file, sometimes, just, want, plain, subroutine, command, prompt, understand, works, call, starts, Questions, Answers, Software