Creating Line Fragments Using QBASIC

QBASIC can create a "line fragment" (a line without the usual carriage-return) with a PRINT statement and a semicolon. If we create the BASIC program on-the-fly, maybe we can still consider it "Batch Programming". 

We'll create the program by ECHOing lines into a .BAS file (Actually, the file doesn't have to have a BAS extension, but it does have to have some kind of extension. QBASIC is picky about that.).

echo open "fragment.txt" for output as #1 > script.bas
echo print #1,"set value="; >> script.bas
echo close #1 >> script.bas
echo system >> script.bas
qbasic /run script.bas
del script.bas > nul

The object of the above code is first to create a basic program called script.bas. When script.bas is run, it will in turn create a one-line file called fragment.txt, our desired "line fragment". Fragment.txt will be just the single line set value= with no carriage return or linefeed. Let's examine the script.bas file which will be created. Since most of it is human-readable, I'll only cover the trick spots. The semicolon on the print line is what suppresses the addition of the carriage return to the end of the line. Don't you wish DOS had a simple option like that? System is used instead of the more widely-known "end" at the end of the program because system will not only stop the program, it will shut down QBASIC as well. Finally, the /run option for QBASIC allows QBASIC to immediately load and run the specified file.

The only bad part of using QBASIC is that your screen will flash briefly as it loads.

Lost? Look at the site map.

Bad links? Questions? Send me mail.

Ask Jeeves