Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows cmd.exe Command-Prompt ► ««« »»»

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.


Contents:

1.) ... Simple example of a sub-function (sub-routine)!
2.) ... More information about CALL calling sub-functions!




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


sub_function.bat

ECHO off
 
::Call under function 2 times 
 
CALL :sub_function 2 5
CALL :sub_function 5 10
ECHO end
 
::Waiting for keypress
PAUSE
 
::END
GOTO :eof
 
:sub_function
SET /a result=%1*%2
 
ECHO %1 mul %2 is %result%
EXIT /B
 


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!
Run the example batch and sub-function on MS Windows all OS!

-
▲ Back to the top ▲



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

With: 

call /?


Get more help on the CALL command, just practice, because practice makes perfect!



See also:

►► Using batch file to start multiple programs!
►► How can I run commands in batch files at intervals?
►► Generate random numbers in the command prompt or batch file!
►► How do I create a batch file on / for MS Windows?





 



FAQ 140: Updated on: 14 June 2022 06:03 Windows
Windows-Console

What are command prompt internal commands?


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
Windows-Console

Rename JPEG to JPG via command line, but how?


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
Windows-Console

Searching in files by string via command prompt?


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
Windows-Console

Deleting files with no content using a batch file, but how?


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
Windows-Console

Is there a list of WMIC commands on MS Windows?


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
Windows-Console

Realize dark mode switch with a batch file?


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
Windows-Console

How and why do command lines work in CMD.EXE?


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
Asked questions on this answer:
Keywords: windows, console, looking, example, subfunction, batch, file, sometimes, just, want, plain, subroutine, command, prompt, understand, works, call, starts, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + MatriX.CoronaKO
  + Find.Same.Images.OK
  + 3D.Benchmark.OK
  + PhotoResizerOK
  + Office.Files.Images
  + Film.Strip.Explorer
  + WinScan2PDF
  + DontSleep
  + ExperienceIndexOK
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.077


► Effective unlocking of gapped files under Windows 10, 8.1, ...! ◄

► Is it legal to make a copy of the MS Windows software! ◄

► Standby Block when the MS Windows 11, 10, .. PC wakes up from standby! ◄

This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....