Hacker News new | ask | show | jobs
by knz42 2897 days ago
The suggestion to "use SYSTEM instead of END" is suspicious.

SYSTEM spawns the system shell as a sub-process. If one would EXIT from the spawned command.com/cmd.exe, QBASIC would pop up back. I think a user of programs written in this way would find themselves surprised.

3 comments

This is not true, system quits basic. In gwbasic this was unconditional since there was no ide, in qbasic it works if you used /run to start the program right away, otherwise system is equivalent to end and just drops you back into the ide.
It was definitely a little confusing, as there seems to be many ways of exiting. From the QBasic docs in the IDE:

END: Ends a program, procedure, block, or user-defined data type. [...] If no argument is supplied, END ends the program and closes all files.

STOP: Halts a program.

SYSTEM: Closes all open files and returns control to the operating system.

You may be thinking of:

SHELL: Suspends execution of a Basic program to run a DOS command or batch file.

SYSTEM with no arguments exited BASIC.

SYSTEM with a string argument on some Microsoft BASICs spawned a shell that ran the command in the argument. On others, the SHELL command did this. (iirc mbasic on xenix used SHELL, GWbasic used SYSTEM with an argument.)