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

Fast start for cmd.exe (Windows Console)?


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

Console command to see IP Address, how to on all Windows OS?


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

Delete and Overwrite permanently?


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

 © 2022 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.061


► Change boot loader Windows 11, 10, ... OS ! ◄ ► Can I still determine the folder sizes on Windows 11? ◄ ► Trusted source? ◄ ► The remote desktop port in Windows? ◄ ► Why have the LED Screen bad pixels and points? ◄ ► Is Adobe Acrobat OEM a full version, which is better for PDFs? ◄ ► Shrink pictures for Instagram, Facebook and co? ◄ ► Run Command Prompt and activate Opacity Mode on Windows 10! ◄
This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....