我目前正在编写一个运行无限循环(循环)的QBASIC程序。但是,如果满足某个条件,我想退出该程序。我使用什么命令,以及语法是什么。
由于
答案 0 :(得分:3)
You're looking for the END
or SYSTEM
statement. For example:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>ddm-timeout-fix</id>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.example.me.TimeoutFix</mainClass>
</configuration>
</execution>
</executions>
</plugin>
If you're using regular old QBASIC/QuickBASIC, then you can ignore all of the QB64 details on the linked pages and just use either PRINT "Hello World!"
END
PRINT "This won't be printed."
or SYSTEM
. Both will do the same thing for the most part.1
If you're using FreeBASIC, it's recommended to use END
instead of END
since some things won't get cleaned up properly when you use SYSTEM
. See SYSTEM
for more information pertaining to FreeBASIC if that's what you're using.
1 The SYSTEM
statement when running the program using END
will print "Press any key to continue" before exiting to the QB/QBASIC environment. The QB.EXE /RUN PROGRAM.BAS
statement when run the same way will simply return you to the DOS shell without any need for a key press. Also, typing SYSTEM
in the "Immediate Window" of the QB/QBASIC environment will exit the environment and return to the DOS shell. Otherwise the two statements behave exactly the same in QB/QBASIC, whether for standalone (compiled) programs or SYSTEM
modules.
答案 1 :(得分:2)
END
退出程序,并清除所有变量,从而释放内存。
STOP
退出程序,但保留所有变量的值,通过从Set next statement
菜单中选择Debug
,可以(在某些版本的QB中)继续在另一个点执行,然后从Start
菜单中Run
。一旦程序终止,END
与STOP
+从Restart
菜单中选择Run
具有相同的效果。
如果你有一个循环,并想要从里面退出程序,你可以使用
DO
IF condition THEN EXIT DO
LOOP
END
或
DO
IF condition THEN END
LOOP
答案 2 :(得分:1)
您可以根据程序的需要保留任何条件。例如:
CLS
LET a = 5
WHILE a > 0
PRINT a;
a = a - 1
WEND
END
这里,程序在wends执行时直到a = 0.这不会运行无限循环。
答案 3 :(得分:-2)
答案是
exit();
退出该计划。