Please enable JavaScript to view this site.

A-Shell Reference

Navigation: Development Topics

SBX Subroutines

Scroll Prev Top Next More

One of the most powerful features of A-BASIC is the ability to call external subroutines using the XCALL statement. Not only are such subroutines useful for modularizing application development, they also encourage code reuse, and perhaps most importantly, they encourage the development of high-quality utility routines that can be shared by a wide cross-section of developers.

Under A-Shell, subroutines are supported, but up until Build 779, they had to be written in C and then linked into the A-Shell executable. Although we make available, on a somewhat customized basis, the tools for developing your own subroutines in C, most would-be subroutine developers have been put off by the technical obstacles and have chosen instead to have us write their routines and then include them in A-Shell. This has resulted in 200+ subroutines being included in the standard A-Shell release, but it has limited the development of new subroutines, especially those that might be useful to more than one developer. It has also created an annoying situation in which minor enhancements to a subroutine require a new version of the A-Shell executable to be linked.

To remedy these shortcomings and to encourage the development of new routines, A-Shell Build 779 introduced the ability to create your own subroutines in BASIC. These subroutines can be fetched dynamically from disk when they are called, and offer most of the normal advantages of subroutines (modularity and true argument passing) plus the additional advantage of being dynamically loaded and thus able to be updated and distributed independent of the A-Shell executable.

Nearly everything said here about writing subroutines also applies to external functions which are invoked via XFUNC.

Subtopics

BASIC or C?

Subroutines vs. Programs

Development Steps

File Handling

Error Trapping

Persistent Variable Storage

Runtime Resolution of Subroutine Names

External (XFUNC) Functions

SBX Parameter Passing

Memory Usage

Loading and Cacheing

Named Parameters in Subroutines

Calling SBX Remotely on ATE Client

Subroutines vs. Functions/Procedures