PowerBASIC

From Wikipedia, the free encyclopedia

Some information in this article or section is not attributed to sources and may not be reliable.
Please check for inaccuracies, and modify and cite sources as needed.

Contents


PowerBASIC is a dialect of the BASIC programming language. Its syntax is similar to that of GW Basic, QBasic, QuickBasic, PDS7 (Microsoft BASIC Professional Development System or QBX), and Turbo Basic.


[edit] Characteristics

PowerBASIC compilers create some of the tiniest and fast .EXEs in the industry. They enable programmers to create applications using the familiar BASIC language that are every bit as robust as those written in other programming languages (such as C). Source code compiles to pure binary (native code), that is, there is no interpreter at all involved in running a PowerBASIC program. PowerBASIC programs don't require external DLLs to run (unless the programmer deliberately designs them to do so). The executable files they create are almost as compact as those written directly in Assembly Language. Programs written in PowerBASIC require no runtime files. Unlike Visual Basic (for example) with its large runtime overhead, it is common for a sophisticated application written in PowerBASIC to be so small it fits on a diskette.

PowerBASIC's compilers are designed to be very compact, by having very compact RTL (Run-time library), to compile very rapidly to create fast, compact programs and DLLs. Applications written in PowerBASIC are close in speed to programs produced with C compilers. There is also the option of even further optimizing speed-critical code with inline assembler. PowerBASIC's 'PowerBASIC for Windows' compiler can create both EXEs and industry-standard DLLs. PowerBASIC's Console Compiler (for Windows) can create web server applications.

PowerBASIC is a popular alternative to Microsoft’s Visual Basic and compares well with C in terms of power. The Windows version PBWin can create both executables and DLLs. Visual Basic programmers often use PowerBASIC to create DLLs to speed the execution of their applications. The programs created by both Windows versions can access independent DLLs if desired.

[edit] Notable Language Features of the Win32 Compilers

  • Array functions
  • DDT (Dynamic Dialog Tools)
  • COM (Common Object Model) client functions
  • Communications: COM ports, UDP, TCP
  • Graphics support
  • Inline assembler, including some SIMD
  • Menu statements for dynamically creating and modifying menus
  • Multi-thread support
  • Printing to Host-based ("Windows-Only") printers
  • Regular Expressions


[edit] Data Types Supported by PBWin and PBCC

Data-type Range of values
Integer -32,768 to 32,767
Long-integer -2,147,483,648 to 2,147,483,647
Quad-integer -9.22x10^18 to +9.22x10^18
Byte 0 to 255
Word 0 to 65,535
Double-word 0 to 4,294,967,295
Single-precision 8.43x10^-37 to 3.40x10^38
Double-precision 4.19x10^-307 to 1.79x10^308
Extended-precision 3.4x10^-4932 to 1.2x10^4932
Currency -9.22x10^14 to +9.22x10^14
Extended-currency -9.22x10^16 to +9.22x10^16
Variant {data-dependent}
Pointers (these are all 32-bit values)
Dynamic String Size limited only by available memory
Fixed-length string Size limited only by available memory
ASCIIZ string Size limited only by available memory
Field string Size limited only by available memory
Variant Supported (no size limitations)
GUID Supported (standard GUID range)
Object Supported (no size limitations)
User-defined data types (UDTs) These are composed of one or more of the intrinsic data types listed above, with the exception of variable-length types such as dynamic strings. Arrays of one and two-dimensions can be included in UDTs, if their data types have a fixed-length.

[edit] Syntax

Some of the syntax differs from other languages for statements dealing with arrays, dialogs and controls. Many of these are multi-word statements. For example, to get a result from scanning an array for a value, the syntax is:

Array Scan a(), = 23, To i

Where the variable "i" receives the result. In typical languages, this would be implemented as a function, for example:

i = ArrayScan(a(), = 23)



[edit] Binary File Size Comparisons

Here are comparisons of PowerBASIC compilers with some of the most efficient compilers.

  • A "Hello World" program compiled by PBWin7 is about 6KB.
  • A "Hello World" program compiled by PureBasic 4 is about 3KB.

The majority of 32-bit compilers don't approach the level of efficiency of the compilers mentioned above. A Visual Basic 6 ActiveX EXE, for example, is around 16KB, and an ActiveX DLL is about 20KB.

[edit] "Hello World" program

This example program displays a messagebox saying "Hello World"

#Compile Exe "Hello.exe"
Function PBMain
   MsgBox "Hello World"
End Function


[edit] Humorous Language Feature

The "#Bloat" metastatement was added to the two Windows compilers apparently somewhat as a joke, but perhaps also to serve a serious purpose. Here's an excerpt from their help file:

Purpose: Artificially inflate the disk image size of a compiled program.
Syntax: #BLOAT size_expression
Remarks: #BLOAT allows the creation of artificially bloated program files on disk, in order to match or exceed that generated by competing "BloatWare" compilers. #BLOAT does not affect the memory image size (running size) of a compiled program.

While #BLOAT adds no true merit to the technical efficiency of the compiled code, there are a number of reasons for its use, including:

  1. To allow "Bloatware" programmers to feel more comfortable when using PowerBASIC.
  2. To impress project leaders/managers with the volume of executable code created.
  3. To allay the fears of uninformed customers who may mistakenly infer that "such tiny programs couldn't possibly do everything that..."
  4. To make certain versions of a program more readily identifiable simply by examining the size of the file on disk.
  5. To improve convolution of the contents of the executable disk image, because the bloat region appears to contain executable code.

[edit] The PowerBASIC Company

PowerBASIC Inc. headquarters is in Venice, Florida, USA. Its president is Bob Zale.

Their slogan is "We put the Power in BASIC"

Despite the large number of free compilers available, they have maintained a loyal following due to their devotion to creating compilers which are small and fast which in turn produce binaries which are small and fast.

They have a strict "no vapour-ware" policy. They maintain a user forum where almost every conceivable programming issue has been addressed, plus a "source code" section where there's code for almost every purpose.

[edit] A (partial) Product History

The commercial DOS version began as Turbo BASIC, published by Borland International.

[edit] PBASIC

  • PBASIC 1.0
  • PowerBASIC 3.1
  • PBDos 3.2
  • FirstBasic1.0 is a shareware version of PBDos with feature limitations.
  • TryPB3.2 is a trial version of PBDos without the ability to load source files.
  • PBDos 3.5 is the latest version of PBDos (as of March 29, 2007)

[edit] PB/DLL / PB/WIN

  • PBDLL 1.0, their first compiler for Windows
  • PBDLL 1.1, included "Direct32 technology"
  • PBDLL 1.5
  • PBDLL 2.0
  • PBDLL 5.0
  • PBDLL 6.0
  • PBDLL 6.1, released December 10, 2001
  • PowerBASIC for Windows v7, commonly referred to as "PBWin". The name was presumably changed to avoid misconceptions of its capabilities.
  • PowerBASIC for Windows v8, released February 18, 2005
  • PowerBasic for Windows v8.03 released December 3, 2006, is their latest version as of March 29, 2007.

[edit] PB/CC

  • PowerBASIC Console Compiler v1.0, released ca. December 12, 1998, and commonly referred to as "PBCC", is designed primarily to produce console (text-mode) programs, although it can also compile needDLLs and GUI-based programs.
  • PowerBASIC Console Compiler v2.0, released May 1, 2000
  • PowerBASIC Console Compiler v2.1, released December 10, 2001
  • PowerBASIC Console Compiler v4.0, released February 18, 2005
  • PowerBASIC Console Compiler v4.02 released September 21, 2006
  • PowerBasic Console Compiler v4.03 released January 03, 2007 is the latest version as of March 29, 2007

[edit] PB/Forms

  • PB/Forms is a visual dialog designer for the PBWin compilers. It generates "DDT" code for the designs which often includes helpful template code for such things as
    • Responding to user events (button-clicks, and so on)
    • Populating controls (TreeViews, ComboBoxes and ListBoxes...)
    • Setting fonts and colors
    • Getting paths to files which have been (dragged and) dropped into the dialog
  • PB/Forms 1.5, released January 22, 2004. This version includes features to automate control layouts:
    • Spacing out controls evenly
    • Resizing controls to same width and/or height
  • PB/Forms 1.51, released February 18, 2005, is the latest version as of March 29, 2007.

[edit] Powershirt

  • PowerShirt 1.0, released February 18, 2005, is a tee-shirt.

[edit] External links

In other languages