Computing: DOS, OS/2 & Windows Programming

Installing and running True BASIC on MS-DOS.

True BASIC is a variant of the BASIC programming language descended from Dartmouth BASIC - the original BASIC. Both were created by college professors John G. Kemeny and Thomas E. Kurtz. True BASIC was introduced in 1985. There are versions of the True BASIC compiler for MS-DOS, Microsoft Windows, and Classic Mac OS. At one time, versions for TRS-80 Color Computer, Amiga and Atari ST computers were offered, as well as a UNIX command-line compiler.

As a difference with most BASIC software of the DOS times, True BASIC was (and is) implemented as a structured programming language. It features global and local variables which make it possible to write recursive functions and subroutines. A particularity of this BASIC dialect is the implementation of statements for matrix arithmetic. True BASIC offers also a very user-friendly way to draw mathematical functions and other graphs: The possibility to define logical windows and custom user coordinate systems allow to directly plot the graph data without the need of any calculations in order to convert the actual x- and y-values into screen coordinates. Something that I myself really liked when trying out the software...

True BASIC 1.0 is available at the WinWorld website, and also at Vetusware. The version used in this tutorial is True BASIC 3.02 that I found on the Russian language website old-dos.ru. I successfully installed and used it on MS-DOS 6.22.

The download archive contains the file system structure of the application. I unzipped it on my Windows 10 host, and copied the whole on a (virtual) floppy diskette. On my MS-DOS machine, I created the directory C:\TRUE (you should use this default installation directory!), and copied the files to there, using the DOS xcopy command. The current directory being C:\ and the files being in the "TRUE" directory on the floppy diskette, here are the commands to "install" the software:
    mkdir true
    cd true
    a:
    cd true
    xcopy *.* c: /s

The screenshot shows the content of the True BASIC installation directory.

True BASIC on MS-DOS: Content of the installation directory

True BASIC comes with a simple IDE (actually called hello.exe). It is black and white only, thus there is no syntax highlighting. On the other hand, the mouse is fully supported. As shows the screenshot below, the screen is divided into 2 windows (use the mouse or the ESC key to switch between them): at the top, the editor window, where you enter the True BASIC source code, and at the bottom, the command window, where you can enter the commands supported by the IDE (running a command from the menu will actually execute this command here); it's also here that the IDE outputs messages about the compilation, and "simple" program output also goes to here. The menu commands may be run either using the mouse, or a keyboard shortcut (ALT+letter). Note, that shortcuts work differently from what we know from most programs. In fact, they immediately execute a command, instead of opening a menu (ex: ALT+F, normally opening the "File" menu, directly runs the "Find" command from the "Edit" menu).

True BASIC on MS-DOS: The True BASIC IDE hello.exe

Note: There seems to be a problem with the Help command. I did not find a way to quit help display. In fact, I think that when running this command, True BASIC and MS-DOS stop responding; I had to use CTRL+ALT+DEL to reboot the computer. To avoid problems, you can for example view the Help topics in the DOS editor...

Here are the essentials for working with the True Basic IDE.

The screenshot below shows how I created a new True BASIC program (hellowld.tru), saved it to disk and executed it using the Run command.

True BASIC on MS-DOS: Running a simple 'Hello World' program

On the screenshots below you can see the output of bounce.tru (on the left) and barchart.tru (on the right), two sample programs included with the installation files.

True BASIC on MS-DOS: Output of the included program sample bounce.tru
True BASIC on MS-DOS: Output of the included program sample barchart.tru

Running the TRC files works fine on the computer where True BASIC is installed, but if we want to run it on another computer, we'll need a DOS executable (.EXE file). Even though the IDE does not support the creation of executables (or did I miss something?), we can create them from the DOS command line by running the program bind.exe, located in the directory C:\TRUE\RUNTIME.

The screenshot shows the binding of hellowld.trc, created by compilation of our hellowld.tru from above, and creating the DOS executable hellowld.exe. Note, that bind.exe may be run with the name of the file to bind as command line parameter, or interactively (the name of the file to bind being asked for in this case).

True BASIC on MS-DOS: Binding a .TRC file in order to create a DOS executable

The executables created seem to run fine on MS-DOS 7.1 and PC-DOS 2000, as well as on Windows 3.x, started from File Manager (I actually tested it on Windows 3.0 Multimedia Edition). On FreeDOS, however, you will probably get the error message True BASIC system error [0908]. The problem seems to be related with the default FreeDOS memory manager (jemmex.exe). If instead, you run FreeDOS with the memory manager himemx.exe (with or without loading jemm386.exe), the executables created by True BASIC run without any problems (this probably also means that the installation of True BASIC on FreeDOS will fail unless you use himemx instead of jemmex).

Custom batch files.

I created two batch files that make working with True BASIC easier. The script tbasic.bat starts the IDE after adding C:\TRUE to the executables path and setting the current directory to C:\DEVEL\TBASIC (the directory that I created for True BASIC development). Here are the commands:
    @echo off
    set path=%path%;c:\true
    cd \devel\tbasic
    c:\true\hello.exe

The second script, tbind.bat binds the TRC file specified as command line argument, the path to my True BASIC development directory being added by the script (the executable also being created in this directory). Here are the commands:
    @echo off
    if "%1"=="" goto Error
    cd \true\runtime
    set program=c:\devel\tbasic\%1.trc
    bind.exe %program%
    set program=
    cd \devel\tbasic
    dir %1.*
    goto Exit
    :Error
    echo Program name missing!
    :Exit

The screenshot shows the binding of nroot.trc (located in the directory C:\DEVEL\TBASIC), by running the command tbind nroot (as the batch file switches to the directory containing bind.exe, you can run it from any directory).

True BASIC on MS-DOS: Binding a .TRC file using a custom batch file

True BASIC program examples.

You can use Google Search to browse the Internet in order to find True BASIC documentation and sample code. I found the True BASIC v5.1 Reference Manual; of course, this does not correspond to the version installed, but the manual can nevertheless be a great help when writing your first True BASIC programs. The 64 pages manual Scientific Programming with True Basic by Prof. D. W. McClure (Chemistry Department, Portland State University) is really well done. It explains the different True BASIC features using real life program examples. You can find several dozens of True BASIC program examples at the Rosetta Code website (the samples nroot.tru and mandel.tru, shown in the following paragraphs are essentially the code published at that site).

The program nroot.tru calculates the 2th to 20th root of a positive number entered by the user. Here is the True BASIC code:

    DEF Nroot (n, a)
        LET p = 0.00001
        LET x1 = a
        LET x2 = a / n
        DO WHILE ABS(x2 - x1) > p
            LET x1 = x2
            LET x2 = ((n - 1) * x2 + a / x2 ^ (n - 1)) / n
        LOOP
        LET Nroot = x2
    END FUNCTION

    LET number = 1
    DO UNTIL number <= 0
        INPUT PROMPT "Please, enter a positive number? ": number
        IF number > 0 THEN
            PRINT " N Root"
            PRINT "================="
            FOR i = 2 TO 20
                LET r = Nroot(i, number)
                PRINT USING "##": i;
                PRINT " ";
                PRINT USING "###.########": r
            NEXT i
        END IF
    LOOP
    END

And here is the program output:

True BASIC on MS-DOS - Sample program: Nth root calculation

The program mandel.tru draws the Mandelbrot Set. As a difference with the code at the Rosetta Code website, my program uses the full screen width and height for the drawing. Also, my program loops until the ESC key (ASCII 27) is pushed. To note that this program is very slow; it will take some minutes before the drawing is finished! Here is the code:

    SET WINDOW 0, 256, 0, 192
    LET x1 = 256
    LET y1 = 192
    LET i1 = -1
    LET i2 = 1
    LET r1 = -2
    LET r2 = 1
    LET s1 = (r2-r1) / x1
    LET s2 = (i2-i1) / y1
    FOR y = 0 TO y1 STEP .05
        LET i3 = i1 + s2 * y
        FOR x = 0 TO x1 STEP .05
            LET r3 = r1 + s1 * x
            LET z1 = r3
            LET z2 = i3
            FOR n = 0 TO 30
                LET a = z1 * z1
                LET b = z2 * z2
                IF a+b > 4 THEN EXIT FOR
                LET z2 = 2 * z1 * z2 + i3
                LET z1 = a - b + r3
            NEXT n
            SET COLOR n - 16*INT(n/16)
            PLOT POINTS: x,y
        NEXT x
    NEXT y
    LET kkey = 0
    DO UNTIL kkey = 27
        GET KEY kkey
    LOOP
    END

The screenshot shows the resulting Mandelbrot Set on my MS-DOS 6.22 VMware virtual machine.

True BASIC on MS-DOS - Sample program: Mandelbrot Set

To see if it is really thus simple to draw functions with True BASIC, I decided to write biorhthm.tru, a simple biorhythm program for 1 month. The screenshot below shows my graphs for August 2024. You can download the source code of this program from the DOS Downloads page in the DOS, OS/2 & Windows Programming section of my site.

True BASIC on MS-DOS - Sample program: biorhythm graphs for one month

If you find this text helpful, please, support me and this website by signing my guestbook.