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
Deleting files without content with a batch file, command prompt, or via the address bar in File Explorer is quite popular Here you can find out. that
It is quite easy to have the MMIC commands listed on all Microsoft Windows desktop and MS servers and to obtain further information WMIC is deprecated The
Why not simply implement the dark mode in Microsoft Windows 11 or 10 with a batch file at the push of a button and without an administrator query Everyone
The command line in CMD.EXE, often also called console or terminal, is a text-based interface within the operating system that can make things a lot easier
»» 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