About PL/B
The PL/B programming language (formerly DATABUS) is a high-level, English-like language that is unrivaled in screen, file and character string manipulation. It is in use all over the world in many different industries. The language is continuing to evolve through the work of Sunbelt in conjunction with input from our many valued customers.
Sunbelt has been writing and selling system software for PL/B programmers since 1980. Our goal is to provide you with the best tools available so you can perform to your customers' expectations.
Products
- PL/B Web Server - HTML5 solution for iOS, Android, and various browsers
- PL/B Application Server - thin client solution
- .NET Framework for PL/B
- Data Manager
- Replication Server
- File Access routines for C and VB
- Windows ODBC Driver
Free demos are available for nearly all of our products.
Features
- Indexed Sequential Access Method (ISAM) for quick data retrieval
- Associative Access Method (AAM) for context-sensitive retrieval and dynamic file updates
- High-level and easy-to-use screen and printer interfaces
- Inherently multiuser
Advantages
- Cross-platform compatibility
- Included ISAM and AAM file access routines
- Built-in screen and print subsystem
- No additional products or libraries needed for high-performance applications
Supported Environments
Linux, Windows 11, Windows 10, Windows 8 or Windows 7.
Programmer's Introduction
This programmer's introduction is courtesy of Stephen G. Kent at Mid Michigan Computer Consultants, Inc. All their information on PL/B can be seen at: Mid Michigan Computer Consultants, Inc.
PL/B is a remarkably simple language to be as powerful as it is. It is extremely robust in all environments, provides support for all major file access methods, runs in every user interface format from text based to GUI and is fully network aware. As a mark of it's power, Sunbelt's PL/B compiler is itself written in PL/B.
PL/B programs lines are composed as:
[LABEL] OPERATION OPERAND,...,[operand] [comments]
The line is essentially free form. The LABEL is optional but when used must start in the first position of the line. The operation is required and must start somewhere past the first position. Label, operation and the first operand are separated by spaces. Operands are separated by commas or qualifiers like "TO", "IN" and "FROM".
Operations have a variable number of operands. When the proper number of operands have been found on a line then anything else is treated as a comment. A period or semi-colon anywhere on the line indicates the start of a comment. Any line may be continued after the first operand by following the last byte of the operand with a colon.
The language is strongly typed with the basic data types being string (called DIM) or numeric (called FORM). Numeric data is defined using a decimal format such as "9.2" indicating the magnitude of the field. Numeric data may also be defined in traditional binary integer, floating point, hex or octal formats.
Unlike some languages, variables may NOT be created implicitly by use. Implicit variables are defined simply by appearing in the code. For example, in BASIC one could code A = 123. "A" becomes a variable but required no previous definition. Implicit variables may be ambiguous when a programmer is working on a small section of unfamiliar code. PL/B requires that variables be specifically defined in advance prior to being used. This insures that there is no ambiguity concerning the variable... with one exception:
PL/B does allow a variable to be reformatted on-the-fly. The SMAKE instruction allows the size of a string variable to be defined at run time. The benefit is that a string variable can be defined in the source code as requiring one byte. At runtime the string can be reformatted on the fly to allow any number of bytes. The effect is that the load module requires less disk space to store. Furthermore, the programmer can write a loop at runtime to expand the variable's size to use all available memory.
As a high level language, PL/B does not require the programmer to be concerned with the actual machine implementation. There are no stack or register or address considerations. This contributes to the highly robust and almost crashproof nature of the language.
PL/B is very easy to read. Instructions formats are intuitive and logical. Variable names maybe up to 32 characters in length thus allowing for very descriptive naming. The language structure falls somewhere between the nearly English format of COBOL and the highly technical format of "C". Programmers from either of those backgrounds adapt quickly to PL/B and generally like it a great deal. (The only exception to the readability comment is where PL/B extends into the realm of Windows API calls. Those are, by definition, difficult for even experienced programmers to interpret.)
Example Code
NAME DIM 30 Working name variable
SAVENAME DIM 30(50) 50-element array of saved names
NAMEIDX FORM " 0" Two byte numeric variable
LOOP
ADD ONE,NAMEIDX Increment index to next array entry
IF (NAMEIDX=50) Is the table full?
BREAK Yes it is, break the loop
ENDIF
KEYIN "Please enter your name:",NAME
MOVE NAME to SAVENAME(NAMEIDX)
DISPLAY "Thank you ",NAME:
". You are number ",NAMEIDX
REPEAT
STOP
Variables
Variables are generally defined as strings or numbers. All variables must be explicitly defined by the programmer. Implicit variables, defined by being used in a statement, are not allowed.
Variables may appear anywhere in the program provided the definition appears in the code before the variables are used in an operation.
Type | Syntax | Description |
---|---|---|
Numeric | label FORM n[.n] |
Defines a numeric variable |
Numeric with initialization | label FORM " 10.33" |
Defines and initializes a numeric variable |
String | label DIM n |
Defines a STRING |
String with initialization | label INIT "xxxx" |
Defines and initializes a string |
Strings (which may be up to 65K in length) are defined by the programmer with a maximum physical length. In actual use, strings have three attributes which may, if needed, be manipulated by the programmer. These attributes are:
- The physical length
- The logical length of the field's current contents
- A "form pointer" designating the first byte within the string that is to be acted on
For example, a 50 byte (physical length) string might contain only 25 bytes of data (logical length) and the pointer might be set to the 5th byte. Strings may be manipulated in whole or, by changing the pointers, as sub-strings. For the most part a programmer simply deals with the entire string.
Arrays
Multi-dimension arrays are specified by declaring variables with an array size defined in parenthesis. (Sunbelt's PL/B supports up to 14 dimensions)
TABLE1 DIM 15(25,25)
General Operations
Operations include the typical ADD, SUBtract, MULTiply, DIVide, MOVE, CALL, BRANCH and GOTO. Calculations may also be done with the CALC statement. For example:
CALC EXTENDED_PRICE = (QUANTITY * PRICE) + DEPOSIT
Logical Operations
Logic operations are typically done with an IF statement such as:
IF (AGE>MAXAGE)
..... routine
ELSE
..... routine
ENDIF
LOOP
CALL GET_USER_NAME_AND_ADDRESS
UNTIL NO_MORE_USERS = TRUE
FOR COUNTER FROM "1" TO "8" USING "2"
DISPLAY COUNTER
REPEAT
STOP
GET_USER_NAME_AND_ADDRESS
KEYIN "Enter your name:",NAME:
*N,"Enter your address:",ADDRESS
..... etc.....
RETURN
OOP
Object oriented programming methodologies are supported by both included code segments and by external calls to pre-compiled modules.
FILE HANDLING
Files are declared as sequential (ASCII) or indexed. Indexed files are simple ASCII files with a separate, self balancing index file. All files may be read randomly or sequentially, forward or backward. Files may have any number of indexes.
PL/B also supports standard Btreive files and a unique content addressed "associative" access method. PL/B can also participate with ODBC defined databases and similar structures.
Most PL/B language vendors provide SQL interfaces and Sunbelt also offers full ODBC support with it's PL/B implementation.
An inline FILE sort is provided by the operation:
[label] SORT "infile, outfile; key,key,key ..."
COMMAND SHELL
In the DOS environment automatic, in-line SHELL's to DOS are provided by an EXECUTE instruction. This same technique works in Windows to call the COMMAND.COM processor.
[label] EXECUTE "command line"
EXTERNAL ROUTINES
PL/B provides for internal subroutines as well as separately compiled, external subroutines.
Text Based Screen I/O
PL/B's most powerful feature, by far, is the text mode screen and keyboard handling. Two instructions do it all. DISPLAY is for output only, KEYIN does both output and input. Popup windows, borders and full color control are all built in. Consider this "popup" routine:
REPLY DIM 1 One byte work area
[label] KEYIN *SETSWALL 5:15:10:50: Define window
*SAVESW: Save screen area
*HON,*BLUE,*HOFF: Blue background
*YELLOW,*DION: Yellow foreground
*ES: Erase screen window
*BORDER: Double line around window
*P3:2: Column 3, Line 2
"Hi there! ": Literal text
*N: Next line
"Tap any key. ": Literal text
*+: Automatic ENTER
REPLY: Get one byte field
*-: Turn off automatic ENTER
*RESTSW; Restore window (popdown)
"Popup windows" may be stacked to almost any level. All screen coordinates may be hardcoded (*P10:25) or use variables (*Pcolumn:row). Colors may optionally be controlled by names (*BLUE) or by specifying a numeric attribute (*COLOR nnn) where nnn may be a variable.
GUI Implementations - VISUAL PL/B
The GUI implementation from Sunbelt, called Visual PL/B is fully compatible with the text based interface. Programs can be coded with a traditional text editor but a visual Integrated Development Environment (IDE) is also provided. The IDE incorporates project management, forms design, language specialized editor, debugging tools, and related tools. The forms designer allows screens to be be created and manipulated with standard visual tools. Properties as well as code segments are attached to each screen object then the objects are packaged into a shell program which provides the overall structure for the application.
Unlike the DOS implementation, which compiles to an "EXE" executable file, the GUI compiler writes to an intermediate, interpreted representation. This machine independent "p-code" can be transported to any platform which supports a PL/B interpreter. Currently supported platforms included various UNIX and LINUX systems and all flavours of Windows including the Pocket PC.
The GUI implementation is conceptually similar to other object oriented languages. Objects are defined and given properties. The application program activates various objects then waits for an event. The event is evaluated and invokes a processing routine to work with the object's results.
A truly unique element of the Sunbelt GUI implementation is the ability to compile and directly run traditional TEXT BASED PL/B programs under WINDOWS with no changes to the code! The text based code is evaluated and the interpreter faithfully replicates keyboard and screen handling within what is essentially a windows text box. (Interestingly, both GUI objects and text based components can be combined in the same program and same screen, which can be very useful.)
CLIENT/SERVER
Sunbelt provides a client/server implementation of the language. The Server program can run on a Windows, Unix or Linux platform. "Thin" client's can run on any remote workstation. The application program is executed on the server. The client program on the remote workstation handles the user interface.
The client program can be downloaded or run from the server via a standard internet browser. A web page would provide a link to the client program on the server. When clicked, the client is downloaded to the remote machine and begins to communicate with the server.
FILE MANAGER
Sunbelt also offers a "File Manager" program which runs on a Windows, Unix or Linux server. Standard PL/B programs running under windows, as well as thin client PL/B programs can communicate with the File Manager using standard TCP/IP connections. All file processing is centralized at the File Manager machine thus optimizing file operations.