Computing: DOS, OS/2 & Windows Programming

Installing and running FreeBASIC on FreeDOS.


FreeBASIC is a free 32-bit compiler for the BASIC language. It is open source and licensed under the GPL. It is designed to be syntax compatible with QuickBASIC, while expanding on the language and capabilities. It can create programs for MS-Windows, DOS and Linux, and is being ported to other platforms. FreeBASIC version 1.07.1a (2019) is included on the FreeDOS 1.3 RC5 Bonus-CD, so no need to separately download it.

I did not arrive to install the Bonus-CD packages with the provided install batch file, thus, I did a manual install. To simplify things for myself, I used 7-Zip to extract the package files (located at {CD-Drive}\PACKAGES\DEVEL) on my Windows 10 machine. The folder structure of the extracted files is made of 3 folders called APPINFO, DEVEL\FBC and SOURCE\FBC respectively. DEVEL\FBC contains the subdirectories, that with base package applications, you'll find under \FREEDOS (in particular BIN, containing the binaries) and an archive called LFNFILES.ZIP, that I extracted to a folder of same name (and deleted the archive). SOURCE\FBC contains an archive called SOURCES.ZIP, that I let as is (I do not intend to use the FreeBASIC sources, thus I will copy the archive as is into my FreeDOS installation). Then, I created an ISO with the extracted files, using the freeware application ISO Workshop.

FreeDOS being installed at C:\FREEDOS and the 3 folders mentioned above being in F:\FBC (F: is the drive letter of my CD drive), here, how I did to install the FreeBASIC files, using the FreeDOS commands copy and xcopy.

Not so evident, if you aren't used to work with DOS, I agree. Anyway, if I find the time, I'll write a small program that, with the path to a package as input, extracts the folder structure and copies everything to the place, where it should be.

The Bonus-CD contains another FreeBASIC related package, called fbc_help, that you can install the same way as we did with the fbc package. The extraction folders (three of them, as for fbc) being in F:\FBC_HELP, and the current directory being the concerned extraction folder:
    COPY *.* C:\FREEDOS\APPINFO
    XCOPY *.* C:\DEVEL\FBC /E /I /H /Q (FBC and not FBC_HELP; always use the directories given by the package filestructure!)
    COPY SOURCES.ZIP C:\FREEDOS\SOURCE\FBC_HELP
And for HTML, only subfolder of F:\FBC_HELP\DEVEL\FBC\LFNFILES.ZIP, copied by the xcopy command above with all its content to C:\DEVEL\FBC\LFNFILES.ZIP:
    XCOPY *.* C:\DEVEL\FBC\HTML /E /I /H /Q (being in C:\DEVEL\FBC\LFNFILES.ZIP\HTML):
    DELTREE LFNFILES.ZIP (being in C:\DEVEL\FBC)

You can build a FreeBASIC application by running FBC.EXE, located in C:\DEVEL\FBC (would have been more logical to place it into C:\DEVEL\FBC\BIN) by adding C:\DEVEL\FBC to the PATH environment variable and entering:
    FBC {source_filename} (being in the directory containing the source file).

Using SET's Editor as FreeBASIC editor on FreeDOS.

The FreeBASIC package does not include a programming editor or IDE. In the Readme file, you can find download links to the two mostly used FreeBASIC development environments FBIDE (available at the FreeBASIC site) and the even more powerful FBEdit. Unfortunately, the programs available for download seem not include a version for DOS. The download archive of the programming editor PFE includes an executable called PFEDOS.EXE, but I got an error message, when trying to run it.

Not a big deal, because there is SET's Editor, an amazing free development environment that may be adapted for any programming or scripting language. SET's Editor is included with FreeDOS 1.3 RC5 and it's even installed by default, not in C:\EDIT, as you should expect, but in C:\APPS. It has syntax highlighting for lots of programming languages, including BASIC and it comes with all the features a programmer can dream of. Probably the mostly configurable programmer editor that exists! I installed Perl 5 on FreeDOS before doing so with FreeBASIC and, not finding a DOS editor specific for Perl, I decided to use SET's editor. As the configuration for FreeBASIC is mostly the same as for Perl, I will not give a detailed description here. Please, have a look at Using SET's Editor as Perl editor on FreeDOS, then return to this page to view the code of the sLisp macro for FreeBASIC and the modifications to make in the menu configuration file to add a FreeBASIC related item to the IDE's Macro menu.

All sLisp macros are stored in the file C:\APPS\SETEDIT\SHARE\SETEDIT\MACROS.SLP, one behind the other and creating a new macro is just adding the sLisp code to this file. Here the macro to take the FreeBASIC source actually being edited, pass it to the FBC compiler and, if there are errors, display those in the editor's Messages window:

    ;*********************************************************
    ; MACRO: FBC
    ; DESCRIPTION: Run Free Basic compiler with file currently being edited
    ; as input. FBC error and warning messages will be displayed in the
    ; Messages window.
    ;*********************************************************

    (defmacro 'FBC'
        (eval
            (setv "input" (WhichEditor))
            (if (length input)
                (eval
                    (setv "program" (+ "fbc" " " input))
                    (eval
                        (setv "output" (RunProgram program))
                    )
                )
            )
        )
    )

The layout of the editor's menu bar is described in the file C:\APPS\SETEDIT\SHARE\SETEDIT\MENUBIND.SMN. Each menu is described by a SubMenu entry, each of its menu items by a MenuItemC entry. Here a partial description of my actual Macro menu in the MENUBIND.SMN file (with menu items for Perl and FreeBASIC added):

    SubMenu: "~M~acro", kbAlM
        MenuItemC: "~R~ecord", cmcRecordMacro, kbShF10, "Shift+F10"
        MenuItemC: "~S~top", cmcStopMacro, kbAlF10, "Alt+F10"
        MenuItemC: "P~l~ay", cmcPlayMacro, kbCtF10, "Ctrl+F10"

        . . .
        MenuSeparator
        MenuItemC: "Run Free ~B~asic compiler", cm(FBC), kbF11, "F11"
        MenuItemC: "Run ~P~erl interpreter", cm(Perl), kbF12, "F12"
    EndSubMenu

ALT+M,B (or F11) compiles the source file actually in the active editor window using the FreeBASIC compiler FBC (producing a DOS executable). ALT+M,P (or F12) runs the script file actually in the active editor window by passing it to the Perl 5 interpreter.

The screenshots below show, how I use the newly created FBC item in the Macros menu to compile the program COLORS.BAS (an example file included with the FreeBASIC distribution (left) and the result of the compilation (right). The SETEdit Messages window shows only two lines: the command run by the macro (the compilation) and the text "Back in the editor". This means that the compilation was successful (and that the executable has been created). If there had been compilation errors, the corresponding error messages would have been displayed in this window.

FreeBASIC on FreeDOS: SETEdit programmers editor - Choosing my custom macro to run the FBC
FreeBASIC on FreeDOS: SETEdit programmers editor - Successful compilation (no errors displayed in the Messages window)

If we have a look into the directory, that contains the FreeBASIC source file (screenshot on the left), we now find there the executable created. An executable of rather huge size, I would say. But don't forget: The FreeBASIC compiler produces 32bit protected mode applications, that are not limited to 640 kB of memory. Typing the name of the executable, will launch it; you can see the result of this on the screenshot on the right.

FreeBASIC on FreeDOS: The directory containing the FreeBASIC source after compilation (executable created)
FreeBASIC on FreeDOS: Successful execution of the FreeBASIC sample program COLORS.BAS

If you want, you can create an FBC batch file, that sets the path to the FBC binaries, navigates to the folder that contains your FreeBASIC sources and then launches SETEdit. Being in the directory with the sources, the Open menu opens automatically in the correct directory. Concerning long file names, I'm not sure. Neither how far FreeBASIC for FreeDOS supports them, nor if you have to load the LFN driver. I myself do so in my batch file. However, I never tried out, what works and what not.


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