Description: |
The CALL command doesn`t support return values as known by other programming languages.
The classic walkaround is to have the function store the return value into a environment
variable. The calling script can use this variable when the function returns.
The :myGetFunc function below demonstrates how the variable var1 gets the "DosTips" string assigned
which can then be used in the calling function.
Note: The var1 variable is reserved for this particular function. Any data stored in
var1 by the calling function before calling :myGetVar will be overwritten. |
Usage: |
1. 2. 3. 4.
|
set "var1=some hopefully not important string"
echo.var1 before: %var1%
call:myGetFunc
echo.var1 after : %var1%
|
|
Script: |
|
Script Output: |
Script Output | var1 before: some hopefully not important string
var1 after : DosTips
| |