China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Can the GOTO in a sub-BAT of WBAT go to the main BAT or other BATs? View 1,589 Replies 3
Original Poster Posted 2005-04-24 00:00 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
23-year member
UID 7105
Gender Male
Status Offline
As the title.
Supplementary: Generally, GOTO can only go to the label of the current BAT, but sometimes it is inconvenient.
Floor 2 Posted 2005-04-26 00:00 ·  中国 河北 石家庄 桥西区 联通
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
This is the common problem of BASIC and BAT, the weakness of GOTO.
DOS之家 http://doshome.com 站长 葛明阳
Floor 3 Posted 2005-04-30 00:00 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re: GOTOmsdos:

Through standardized program design, it is possible to achieve Goto or Call in Bat to its own or other Bat labels.

Structure of the calling side
...
:: Call - type call to itself
call %0 : labelname
...
:: Goto - type call to itself
%0 : lablename
...
:: Call - type call to other Bat
call bat_name : labelname
...
:: Goto - type call to other Bat
bat_name : lablename
...


Structure of the called side
@echo off
if "%1"==":" goto %2
...
:labelname
...
goto end
...
:end

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 4 Posted 2005-04-30 00:00 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
23-year member
UID 7105
Gender Male
Status Offline
willsort is here.
After taking a look, it's pretty good. Skillfully passing through %1 %2, making up for the shortcomings! Another problem is solved! I'll give it a try...
Forum Jump: