成人性生交大片免费看视频r_亚洲综合极品香蕉久久网_在线视频免费观看一区_亚洲精品亚洲人成人网在线播放_国产精品毛片av_久久久久国产精品www_亚洲国产一区二区三区在线播_日韩一区二区三区四区区区_亚洲精品国产无套在线观_国产免费www

主頁 > 知識(shí)庫 > DOS批處理 函數(shù)定義與用法

DOS批處理 函數(shù)定義與用法

熱門標(biāo)簽:呼倫貝爾外呼系統(tǒng) 如何申請400電話業(yè)務(wù)mm 玉林市機(jī)器人外呼系統(tǒng)哪家好 雷霆電銷機(jī)器人怎么樣 智能打電話機(jī)器人收費(fèi) 電話機(jī)器人產(chǎn)品怎么樣 電話機(jī)器人全國招商 清遠(yuǎn)百度地圖標(biāo)注店鋪位置 如何弄地圖標(biāo)注

What it is, why it`s important and how to write your own.

Description: The assumption is: A batch script snippet can be named a function when:

1.... it has a callable entrance point.
2.... on completion execution continues right after the command that initially called the function.
3.... it works the same no matter from where it`s being called, even when it calls itself recursively.
4.... the variables used within a function do not conflict with variables outside the function.
5.... it exchanges data with the calling code strictly through input and output variables or a return code.

The benefits behind functions are:

1.Keep the main script clean
2.Hide complexity in reusable functions
3.Test functions independently from the main script
4.Add more functionality to your batch script simply by adding more functions at the bottom
5.Don`t worry about the function implementation, just test it and use it
 
Create a Function What is a function?
Call a Function How to invoke a function?
Example - Calling a Function An Example showing how it works.
Passing Function Arguments How to pass arguments to the function?
Parsing Function Arguments How to retrieve function arguments within the function?
Example - Function with Arguments An Example showing how it works.
Returning Values the Classic Way The classic way of returning values and the limitations.
Returning Values via References Let the caller determine how to return the function result and avoid the need of dedicated variables.
Example - Returning Values using Variable Reference An Example showing how it works.
Local Variables in Functions How to avoid name conflicts and keep variable changes local to the function?
Returning Local Variables How to pass return values over the ENDLOCAL barrier?
Recursive Functions Tadaaah!!!
Summary Defining a standard format for a DOS batch function
DOS Batch - Function Tutorial What it is, why it`s important and how to write your own.

Create a Function - What is a function
Description: In DOS you write a function by surrounding a group of command by a label and a GOTO:EOF command. A single batch file can contain multiple functions defined like this. The label becomes the function name.
Script:

復(fù)制代碼 代碼如下:

:myDosFunc    - here starts my function identified by it`s label
echo. here the myDosFunc function is executing a group of commands
echo. it could do a lot of things
GOTO:EOF

 

Call a Function - How to invoke a function
Description: A function can be called with the CALL command followed by the function label.
Script: 01.
 call:myDosFunc

Example - Calling a Function - An Example showing how it works
Description: The use of batch functions will divide the script into two sections.

1.The main script: starting at line 1 ending with a GOTO:EOF command that terminates the script.
2.The function section: filling the second half of the batch file with one or more functions to be callable from the main script.
 
Script:

復(fù)制代碼 代碼如下:

@echo off
echo.going to execute myDosFunc
call:myDosFunc
echo.returned from myDosFunc

echo.pausegoto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myDosFunc    - here starts my function identified by it`s label
echo.  here the myDosFunc function is executing a group of commands
echo.  it could do a lot of things
goto:eof


 
Script Output:   Script Output 
going to execute myDosFunc
  here the myDosFunc function is executing a group of commands
  it could do a lot of things
returned from myDosFunc
Press any key to continue . . .
 
Passing Function Arguments - How to pass arguments to the function
Description: Just as the DOS batch file itself can have arguments, a function can be called with arguments in a similar way. Just list all arguments after the function name in the call command.
Use a space or a comma to separate arguments.
Use double quotes for string arguments with spaces.
Script:

復(fù)制代碼 代碼如下:

call:myDosFunc 100 YeePEE
call:myDosFunc 100 "for me"
call:myDosFunc 100,"for me"

 
Parsing Function Arguments - How to retrieve function arguments within the function
Description: Just as the DOS batch file itself retrieves arguments via %1 … %9 a function can parse it`s arguments the same way. The same rules apply.
Let`s modify our previews example to use arguments.
To strip of the double quotes in an arguments value the tilde modifier, i.e. use %~2 instead of %2.
Script:

復(fù)制代碼 代碼如下:

 :myDosFunc    - here starts myDosFunc identified by it`s label
echo.
echo. here the myDosFunc function is executing a group of commands
echo. it could do %~1 of things %~2.
goto:eof

 
Example - Function with Arguments - An Example showing how it works
Description: The following example demonstrates how to pass arguments into a DOS function. The :myDosFunc function is being called multiple times with different arguments.

Note: The last call to myDosFunc doesn`t use double quotes for the second argument. Subsequently "for" and "me" will be handled as two separate arguments, whereas the third argument "me" is not being used within the function.
Script:

復(fù)制代碼 代碼如下:

 @echo off
echo.going to execute myDosFunc with different arguments
call:myDosFunc 100 YeePEE
call:myDosFunc 100 "for me"
call:myDosFunc 100,"for me"
call:myDosFunc 100,for me
echo.pausegoto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myDosFunc    - here starts my function identified by it's label
echo.
echo. here the myDosFunc function is executing a group of commands
echo. it could do %~1 of things %~2.
goto:eof


 
Script Output:   Script Output 
going to execute myDosFunc with different arguments
 
 here the myDosFunc function is executing a group of commands
 it could do 100 of things YeePEE.
 
 here the myDosFunc function is executing a group of commands
 it could do 100 of things for me.
 
 here the myDosFunc function is executing a group of commands
 it could do 100 of things for me.
 
 here the myDosFunc function is executing a group of commands
 it could do 100 of things for.
 
Press any key to continue . . .
 

Returning Values the Classic Way - The classic way of returning values and the limitations
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:

復(fù)制代碼 代碼如下:

 set "var1=some hopefully not important string"
echo.var1 before: %var1%
call:myGetFunc
echo.var1 after : %var1%

 
Script:

復(fù)制代碼 代碼如下:

 :myGetFunc    - get a value
set "var1=DosTips"
goto:eof

 
Script Output:   Script Output 
var1 before: some hopefully not important string
var1 after : DosTips
 
Returning Values via References - Let the caller determine how to return the function result and avoid the need of dedicated variables
Description: Instead of using "global" variables for return value, the function can use one of it`s arguments as variable reference. The caller can then pass a variable name to the function and the function can store the result into this variable making use of the command line expansion of the command processor:

Note: The var1 variable is not reserved for this articular function. Any variable can be passed to the function the caller has full control.
Usage:

復(fù)制代碼 代碼如下:

 call:myGetFunc var1
echo.var1 after : %var1%

 
Script:

復(fù)制代碼 代碼如下:

 :myGetFunc    - passing a variable by reference
set "%~1=DosTips"
goto:eof

 
Script Output:   Script Output 
var1 after : DosTips
 
Example - Returning Values using Variable Reference - An Example showing how it works
Description: This code shows how the var1 variable is being passed into a :myGetFunc function simply by passing the variable name. Within the :myGetFunc function the command processor works like this:
1.Reads the set command into memory: set "%~1=DosTips"
2.Expand the variables, i.e. %~1 like this: set "var1=DosTips"
3.Finally execute the command and assign the new string to var1
 
Script:

復(fù)制代碼 代碼如下:

 @echo off

set "var1=CmdTips"
echo.var1 before: %var1%
call:myGetFunc var1
echo.var1 after : %var1%

echo.pausegoto:eof


::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myGetFunc    - passing a variable by reference
set "%~1=DosTips"
goto:eof


 
Script Output:   Script Output 
var1 before: CmdTips
var1 after : DosTips
 
Press any key to continue . . .
 

Local Variables in Functions - How to avoid name conflicts and keep variable changes local to the function
Description: The SETLOCAL causes the command processor to backup all environment variables. The variables can be restored by calling ENDLOCAL. Changes made im between are local to the current batch. ENDLOCAL is automatically being called when the end of the batch file is reached, i.e. by calling GOTO:EOF.
Localizing variables with SETLOCAL allows using variable names within a function freely without worrying about name conflicts with variables used outside the function.
Script:

復(fù)制代碼 代碼如下:

 @echo off

set "aStr=Expect no changed, even if used in function"
set "var1=No change for this one.  Now what?"
echo.aStr before: %aStr%
echo.var1 before: %var1%
call:myGetFunc var1
echo.aStr after : %aStr%
echo.var1 after : %var1%

echo.pausegoto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myGetFunc    - passing a variable by reference
SETLOCAL
set "aStr=DosTips"
set "%~1=%aStr%"
ENDLOCAL
goto:eof


 
Script Output:   Script Output 
aStr before: Expect no changed, even if used in function
var1 before: No change for this one.  Now what?
aStr after : Expect no changed, even if used in function
var1 after : No change for this one.  Now what?
 
Press any key to continue . . .
 
Returning Local Variables - How to pass return values over the ENDLOCAL barrier
Description: The question is: When localizing a function via SETLOCAL and ENDLOCAL, how to return a value that was calculated before executing ENDLOCAL when ENDLOCAL restores all variables back to its original state?
The answer comes with "variable expansion". The command processor expands all variables of a command before executing the command. Letting the command processor executing ENDLOCAL and a SET command at once solves the problem. Commands can be grouped within brackets.
Script:

復(fù)制代碼 代碼如下:

 @echo off

set "aStr=Expect no changed, even if used in function"
set "var1=Expect changed"
echo.aStr before: %aStr%
echo.var1 before: %var1%
call:myGetFunc var1
echo.aStr after : %aStr%
echo.var1 after : %var1%

echo.pausegoto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myGetFunc    - passing a variable by reference
SETLOCAL
set "aStr=DosTips"
( ENDLOCAL
    set "%~1=%aStr%"
)
goto:eof

:myGetFunc2    - passing a variable by reference
SETLOCAL
set "aStr=DosTips"
ENDLOCALset "%~1=%aStr%"       rem THIS ALSO WORKS FINE
goto:eof


 
Script Output:   Script Output 
aStr before: Expect no changed, even if used in function
var1 before: Expect changed
aStr after : Expect no changed, even if used in function
var1 after : DosTips
 
Press any key to continue . . .

Recursive Functions - Tadaaah!!!
Description: Being able to completely encapsulate the body of a function by keeping variable changes local to the function and invisible to the caller we are now able to call a function recursively making sure each level of recursion works with its own set of variables even thought variable names are being reused.

Example: The next example below shows how to calculate a Fibonacci number recursively. The recursion ss when the Fibonacci algorism reaches a number greater or equal to a given input number.
The example starts with the numbers 0 and 1 the :myFibo function calls itself recursively to calculate the next Fibonacci number until it finds the Fibonacci number greater or equal 1000000000.

The first argument of the myFibo function is the name of the variable to store the output in. This variable must be initialized to the Fibonacci number to start with and will be used as current Fibonacci number when calling the function and will be set to the subsequent Fibonacci number when the function returns.
Script:

復(fù)制代碼 代碼如下:

 @echo off

set "fst=0"
set "fib=1"
set "limit=1000000000"
call:myFibo fib,%fst%,%limit%
echo.The next Fibonacci number greater or equal %limit% is %fib%.

echo.pausegoto:eof


::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myFibo  -- calculate recursively the next Fibonacci number greater or equal to a limit
::       -- %~1: return variable reference and current Fibonacci number
::       -- %~2: previous value
::       -- %~3: limit
SETLOCAL
set /a "Number1=%~1"
set /a "Number2=%~2"
set /a "Limit=%~3"
set /a "NumberN=Number1 + Number2"
if /i %NumberN% LSS %Limit% call:myFibo NumberN,%Number1%,%Limit%
(ENDLOCAL
    IF "%~1" NEQ "" SET "%~1=%NumberN%"
)
goto:eof


 
Script Output:   Script Output 
The next Fibonacci number greater or equal 1000000000 is 1134903170.
 
Press any key to continue . . .
 
Summary - Defining a standard format for a DOS batch function
Description: With the information learned in this section we can define a standard format for a DOS batch functions as shown below.
Also check out the rich set of ready to use DOS functions provided by the DosTips.com function library.
Script:

復(fù)制代碼 代碼如下:

 :myFunctionName    -- function description here
::                 -- %~1: argument description here
SETLOCAL
REM.--function body here
set LocalVar1=...
set LocalVar2=...
(ENDLOCAL REM -- RETURN VALUES
    IF "%~1" NEQ "" SET %~1=%LocalVar1%
    IF "%~2" NEQ "" SET %~2=%LocalVar2%
)
GOTO:EOF

出處:http://www.dostips.com/DtTutoFunctions.php

標(biāo)簽:樂山 白銀 公主嶺 株洲 蕪湖 江西 臺(tái)州 三門峽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《DOS批處理 函數(shù)定義與用法》,本文關(guān)鍵詞  DOS,批處理,函數(shù),定義,與,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《DOS批處理 函數(shù)定義與用法》相關(guān)的同類信息!
  • 本頁收集關(guān)于DOS批處理 函數(shù)定義與用法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    国产精品免费网站在线观看| 国产欧美日韩一区二区三区在线观看| 欧美性大战久久久久| 国产精品高清一区二区| 中文字幕人妻一区二区三区视频| 成人午夜免费影院| 国产成人在线精品| 精品国产一区二区三区四区四| 日产精品久久久一区二区| 欧美日韩国产中文精品字幕自在自线| 一区二区三区免费播放| 免费看的黄色欧美网站| 1区2区在线观看| 天天舔天天干| 偷偷要色偷偷| 欧美日韩国产色综合一二三四| 亚洲网站在线看| 亚洲男人的天堂在线播放| 国产黄色片视频| 国产精品a久久久久| 亚洲国产精品毛片| 伊人精品在线视频| 日韩精品伦理第一区| 欧美男男同志| 日韩精品在线免费播放| 热久久视久久精品18亚洲精品| 欧美性aaa| 91夜夜揉人人捏人人添红杏| 亚洲一区二区三区在线免费| 7777免费精品视频| 久久久久久久综合狠狠综合| 国产精品激情av电影在线观看| 国产日韩欧美在线一区| 欧美成人三级| 天堂av中文在线资源库| 在线成人午夜影院| 国产欧美日韩一级| 少妇精品无码一区二区免费视频| 成人久久网站| 18涩涩午夜精品.www| thepron国产精品| 亚洲成av人片在线观看无码| 成人高清在线观看视频| 日本成人在线网站| 天海翼一区二区三区四区在线观看| 在线播放欧美女士性生活| 福利小视频网站| 五月天婷婷综合| 日韩中文字幕高清| 国产绳艺sm调教室论坛| 欧美精品一二三区| 久久国产精品亚洲人一区二区三区| 91人人澡人人爽人人精品| 欧美性猛片aaaaaaa做受| 日韩中文字幕第一页| 成人免费毛片片v| 免费人成在线观看| 成人午夜电影免费在线观看| 亚洲不卡av一区二区三区| 欧美精品一区二区视频| xxx一区二区| 欧美激情久久久久久久| 真实国产乱子伦精品一区二区三区| 动漫一区在线| 狠狠操狠狠色综合网| 中文日韩在线观看| 国产伦理久久久| 久久久久久视频| 亚洲色图综合图区| 国产精品自产拍在线观看2019| 少妇人妻丰满做爰xxx| av成人 com a| 色诱色偷偷久久综合| 91精品国产高清一区二区三蜜臀| 国产精品成人一区| 国产日产在线观看| 精品人妻一区二区三区四区不卡| fc2人成共享视频在线观看| 亚洲第一av网站| 91久久人澡人人添人人爽欧美| 欧美人妖在线| 中文字幕一区二区三区四区久久| av福利导福航大全在线| 亚洲国产精品免费视频| 国产精品久久乐| 日韩女优制服丝袜电影| 国产日韩成人内射视频| 成人免费看黄网站| xxxxx91麻豆| 俺也去精品视频在线观看| 91福利在线导航| 久久福利资源站| 99国产精品久久久久久久久久久| 亚洲欧洲精品天堂一级| 亚洲欧美第一页| 91玉足脚交嫩脚丫在线播放| 午夜久久久久久久久久影院| 国内黄色精品| 国产一区二区精品久久| 丝袜美腿小色网| 林ゆな中文字幕一区二区| 国产亚洲电影| 久88久久88久久久| 欧美三级午夜理伦三级在线观看| 亚洲尤物视频网| 黑鬼狂亚洲人videos| 88在线观看91蜜桃国自产| 无码任你躁久久久久久老妇| 久久人人爽人人爽人人片av高请| 人人妻人人添人人爽欧美一区| 国产精品激情av在线播放| 中文字幕一区二区三区在线观看| 亚洲精品欧美| 日本成人网址| 免费一区二区| 日韩欧美中文一区二区| 中文字幕av一区二区三区人妻少妇| 国产丝袜欧美中文另类| 亚洲午夜在线| 国产成人一二| 又色又爽又黄18网站| 在线观看欧美日本| 全球av集中精品导航福利| av在线电影播放| 黄色影院在线看| 国产欧美va欧美不卡在线| 日韩成人在线播放| 精品一区二区三区中文字幕| 91av在线免费观看| 卡一卡2卡三精品| 国产高清视频免费观看| 亚洲国产精品网站| 天天操精品视频| 欧美亚洲图片小说| 国产aⅴ超薄肉色丝袜交足| 国内一区二区在线| 在线播放中文字幕| 99热免费在线观看| 狠狠色综合网| 男男做爰猛烈叫床爽爽小说| 老汉av免费一区二区三区| 欧美国产一区二区在线观看| 天天干天天操av| 精品国产影院| 欧美人妇做爰xxxⅹ性高电影| 色老板视频在线观看| 国产原厂视频在线观看| 精品1区2区3区4区| 伊人影院中文字幕| 美女被爆操网站| 欧美极品一区| xxx在线播放| 国产在线黄色| 性色视频在线| 国产欧美亚洲日本| 最近中文在线观看| 精品一区不卡| a中文字幕www| 深田咏美中文字幕| 在线播放av网站| 亚洲免费在线播放| 欧美日韩一区二区三| 中文字幕成人一区| 欧美黑人又粗又大又爽免费| 欧美国产偷国产精品三区| 亚洲av无码乱码国产麻豆| 91视频免费观看| 国产精品最新在线观看| 国产日韩高清一区二区三区在线| 成人av在线网址| 91精品国产综合久久香蕉的用户体验| 丝袜在线观看| 国产视频每日更新| 日本电影免费看| 久久米奇亚洲| 国产日韩欧美一区二区三区| 日韩精品欧美激情一区二区| 美女脱光内衣内裤视频久久影院| 亚洲欧美另类在线| 久久婷婷国产麻豆91| 国产精品sss在线观看av| 日韩伦理在线| 制服国产精品| 成人午夜天堂| 久久精品凹凸全集| 影音av在线| 亚洲精品日日夜夜| 亚洲精品自产拍在线观看| www.激情小说.com| 高清成人在线| 狼人精品一区二区三区在线| 亚洲一区二区精品在线观看| fc2在线中文字幕| 成人av网址在线| 日韩免费视频播放| 欧美性xxxxxbbbbbb精品| 呦呦在线视频| 久久精品国产第一区二区三区最新章节| 天堂视频在线观看免费| 亚洲爆乳无码精品aaa片蜜桃| 中文字幕免费在线观看视频| 久久伊人成人网| 日韩精品极品毛片系列视频| 中文字幕一级片| 欧美性色综合网| 日本免费黄色| 国产精品久久二区| av在线免费观看网| 九九综合九九| 国产xxx69麻豆国语对白| 亚洲a∨日韩av高清在线观看| 欧洲综合视频| 日韩欧美一级在线| 成人一区二区三区在线观看| 在线播放免费| 蜜桃在线一区二区三区精品| 16—17女人毛片毛片| 国产精品久久无码一三区| av在线免费看片| 黑人巨大精品欧美一区二区奶水| 成人晚上爱看视频| 国产中文一区| 欧美精品一区在线播放| 91免费看蜜桃| 性色av一区二区怡红| 欧美一级淫片a免费视频| 美丽的姑娘在线观看免费动漫| www.国产二区| 狠狠爱在线视频一区| 欧美特黄一区二区三区| 欧美性做爰猛烈叫床潮| 国产免费黄色录像| 国产黄a三级三级三级| 欧美成人激情图片网| 亚洲一区二区三区在线免费| 天堂在线中文网| 日韩av在线电影| 先锋资源一区二区| 日韩中文字幕第一页| 久久久.www| 亚洲免费精彩视频| h视频在线观看免费网站| 五月天中文字幕一区二区| 日本精品网站| 99精品在免费线偷拍| 韩国三级日本三级少妇99| 午夜精品99久久免费| 在线观看xxxxvideo| 国产在线精品一区二区三区》| 国产精品成人一区二区三区| 亚洲成人资源在线| 国产97色在线 | 日韩| 国产免费麻豆视频| 一区二区三区久久网| 男女午夜激情视频| 特级丰满少妇一级aaaa爱毛片| 亚洲精品福利资源站| 国产成人在线视频免费观看| 欧美性三三影院| 欧美激情综合亚洲一二区| 久久发布国产伦子伦精品| 亚洲xxxxxx| 久久激情视频免费观看| 精品国产乱码久久久久久樱花| 国产又黄又大又粗的视频| 国产精品美腿一区在线看| 色悠悠久久88| 国产精品理论在线| 久久视频在线视频| 亚洲一级一区| 成人欧美一区二区三区在线| 中文av一区二区三区| gogogo高清在线观看免费完整版| 在线中文一区| 日韩中文字幕在线免费观看| 无码人妻丰满熟妇区五十路百度| 在线看的片片片免费| 色猫猫国产区一区二在线视频| 久久久国产在线视频| 免费无码av片在线观看| 91成人高清| 69久久夜色精品国产69蝌蚪网| 欧美日韩一区综合| 懂色av中文一区二区三区天美| 精品国精品国产自在久国产应用| 免费在线播放电影| 中文字幕 欧美日韩| av电影在线观看完整版一区二区| 欧美视频一区二区三区| 欧美成人免费视频| 另类小说一区二区三区| 激情中国色综合| 亚洲第一免费网站| 久久久久久久久99| 91高清在线| 日韩精品视频在线观看网址| 自拍偷拍精品| 国产三级视频在线播放| 久久精品国产亚洲AV无码男同| 国产精品视频午夜| 亚洲色图第四色| 亚洲国产专区| 在线观看污视频| 亚洲色偷偷色噜噜狠狠99网| 91精品福利在线一区二区三区| 一级毛片免费播放| 日韩欧美在线观看免费| 老司机av福利| 黄色一级片国产| 国产精品久久久国产盗摄| 中文字幕国产精品| 国产精品77777竹菊影视小说| av电影网站在线观看| 亚洲一区美女视频在线观看免费| 人人干人人插| 在线观看色视频| 欧美日韩一级大片| 久久国产三级| 中国麻豆视频| 国模大尺度一区二区三区| 久久精品国产亚洲777| 校园春色亚洲| 91精品国产福利| 天堂av最新在线| 中文字幕在线天堂| 97精品在线观看| 四虎永久免费网站| 99riav久久精品riav|