国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

11.25 批處理 函數(shù)

2023-07-20 11:23 作者:小步2023  | 我要投稿

詳情鏈接地址? ? https://www.xiaobuteach.com/dos/bat/function.html?from=bili

批處理 函數(shù)

批處理中函數(shù)是借助標(biāo)簽來實(shí)現(xiàn)。這里我們介紹函數(shù)定義、函數(shù)調(diào)用、函數(shù)參數(shù)、函數(shù)返回值。


1 函數(shù)定義

:函數(shù)名 函數(shù)體 goto:eof

1)冒號+函數(shù)名 本質(zhì)是定義標(biāo)簽,冒號后的名稱也就是函數(shù)名。

2)goto:eof 表示退出函數(shù)。


示例代碼

批處理文件內(nèi)容如下。

:sum ?echo 調(diào)用函數(shù)sum執(zhí)行求和. xiaobuteach.com ?set /a result = 0 ?for /L %%i in ( 1 1 10) do ( ? ?set /a result = result + %%i ?) ?echo 結(jié)果為:%result% goto:eof

2 函數(shù)調(diào)用

通過call實(shí)現(xiàn)函數(shù)調(diào)用。

call :函數(shù)名

示例代碼

call :sum

完整代碼如下

@ echo off echo 第1次調(diào)用sum call :sum echo/ echo/ echo 第2次調(diào)用sum call :sum pause exit /B 0 :sum ?echo 調(diào)用函數(shù)sum執(zhí)行求和. xiaobuteach.com ?set /a result = 0 ?for /L %%i in ( 1 1 10) do ( ? ?set /a result = result + %%i ?) ?echo 結(jié)果為:%result% goto:eof

代碼說明

1)exit /B 0:表示退出當(dāng)前程序,但不退出控制臺。

2)函數(shù)的定義通常放在文件的最后。

3)主程序的代碼最后通常會使用exit /B 0,否則最后會多執(zhí)行一次函數(shù)中的內(nèi)容。


運(yùn)行結(jié)果


11.25 批處理 函數(shù)的評論 (共 條)

分享到微博請遵守國家法律
海伦市| 咸宁市| 惠安县| 灵璧县| 井冈山市| 仁化县| 綦江县| 乌什县| 贡觉县| 景东| 绥江县| 阿克苏市| 江川县| 富蕴县| 普陀区| 沧州市| 墨竹工卡县| 三原县| 阿克陶县| 黔西县| 庆阳市| 中山市| 黑河市| 耒阳市| 樟树市| 大化| 资兴市| 松江区| 西华县| 环江| 鲁山县| 乐东| 上蔡县| 秀山| 本溪| 吉安市| 芦山县| 永新县| 繁昌县| 大渡口区| 桐庐县|