PowerBASIC Console Compiler for Windows

By Tom Cone, Tampa PC Users Group

The PowerBASIC Console Compiler for Windows creates EXEcutables (.EXE) capable of running in the Win32 environment (Windows 95, 98 and NT). It’s published by PowerBASIC,316 Mid Valley Center, Carmel, CA 93923. (http://www.powerbasic.com)

The program features an Integrated Development Environment for writing and debugging your BASIC code. It will feel very familiar to you if you ever worked in QuickBASIC, PowerBASIC for DOS, or (even longer ago) TurboBASIC.

What is a Console?

A console is a text mode interface connected right to the heart of 32-bit Windows. If you double-click on the MS-DOS icon in Windows, the window that opens with the C:\> prompt is your text console. In it you can execute commands such as DIR, CLS, COPY, etc.Hermes Replica Handbags Additionally, you can run text mode applications such as XCOPY32.EXE and PING.EXE. These programs are actually 32-bit Windows applications which use special calls to the Win32 API in order to display text inside of the console window.

PB/CC eliminates the need for you to learn these special Win32 API calls in order to create console applications. The whole process is handled for you when you use the PRINT, LOCATE, COLOR, CLS, and other statements in the PB/CC language. This frees you to concentrate on the task at hand.

While not every application written for Windows will need to be a console application, the console seems suitable for many types of tasks. I, for example, have long been interested in database programming. Databases do not require sophisticated graphical components. Usually, it’s "heads down" full speed keypunching data entry that’s more important. Speed and ease of use are valued more highly than pretty screens. In that setting, having to lift your hand off the keyboard to position and click the mouse slows one down.

Every programmer is familiar with the "Hello, World!" program. It simply displays the greeting text to an end user. While not a significant program, it does measure two important things. The amount of source it takes to write a complete application, and the size of the executable generated by the compiler.

In Visual Basic I believe you have to create a form with a static text label and write the code to change the label. You then have to set the text of the label. And finally you have to access several different menu items and property sheets in order to configure VB to compile a true EXE as small as it possibly can. The result? About 1.9 megabytes of executable and runtime DLL files, I’ve been told from reliable sources..

In PB/CC only three lines of code are necessary,

PRINT "Hello, World!"

And the PB/CC compiler takes care of the rest automatically.

There are some differences.Replica Burberry Shoulder Bag Unlike most DOS versions of BASIC, PB/CC requires that all executable code be contained inside of a Sub or Function. Only scanned statements (such as meta-statements, constant declarations and procedure declarations) can be placed outside of Subs and Functions.

The following PB/DOS program:

PRINT "At the tone the time will be "; TIME$

Simply needs to be placed inside of a Function called PbMain() in order to execute:

PRINT "At the tone the time will be "; TIME$

When your program is loaded, the function PbMain() is executed automatically by PB/CC. This is where the main code of your application should be placed. The program stops when there are no more statements in PbMain() or an EXIT FUNCTION is encountered.

By default, all variables are local to Subs and Functions. Which means they can not be seen by other Subs or Functions. If you need to share a variable or array throughout your program, you should use the GLOBAL statement to change the scope. This promotes modular programming styles, which can lead to more efficient programming and easier debugging.

Besides the text console interface, the publisher says PB/CC offers BASIC programmers complete access to the complete Win32 API. It supports all true 32 bit DLL’s, including the Winsock API for Internet access and ODBC for accessing SQL and other database servers. Win32 console applications also have a 2 gigabyte flat memory address, so trying to fit everything into 640k or 16 megs of EMS memory is no longer required. A string variable can be many megabytes in size and the limitation on arrays is measured in gigabytes instead of 'k' bytes.

Here’s a sample, furnished by the publisher, which I’ve modified to contain explanatory notes and to cause the text mode interface to remain on screen until the user presses a key.

Hello, World!
Copyright (c) 1998 by PowerBASIC, Inc. All Rights Reserved.
Modifications by Tom Cone, 6/23/98

‘$RESOURCE "HELLO.PBR" 'embed icon in executable if desired
FUNCTION PBMAIN() AS LONG 'PbMain is a user-defined function called
'by Windows TO begin execution of an

COLOR 7,1 'set to white on blue
LOCATE 15, 10
PRINT "Hello, World!" ;
WAITSTAT 'wait for any key
'program will end, and console
'will close.

The foregoing code compiled to an EXE that was 9,725 bytes in size. That’s less than 10k of 32 bit code. The program will run under Windows 95, Windows 98, and Windows NT. It will not run under Windows 3.x When you run the program a text mode window opens on screen. It’s resizable and moveable with your mouse. It seems to behave exactly like a DOS mode program, except that it’s actually a 32 bit Windows program. If you’re curious what it looks like, send me your e-mail address and I’ll send it to you.

The program has other features including support for WinCGI applications, but does not support ActiveX controls. However, it does include support for threaded processes, an inline assembler, and other advanced features that I’m not familiar with (yet).

System Requirements

PB/CC version 1.0 is priced at $149 plus shipping.

Documentation for this product is provided in electronic form, as it allows the maximum amount of information, without the physical size limits of a book. Optionally, printed documentation can be purchased for $29 plus shipping. u