Programming

BASIC libraries galore

Steve Drain has released a number of BASIC libraries, and a new version of the Basalt module.

The Strings BASIC library provides routines for handling long strings, referenced by normal string variables. All the standard string keywords are emulated and work with any combination of normal string variables and expressions and long strings. Written to explore a new idea for providing long string support in Basalt, which is yet to be fully written, Steve is releasing the library because it may be of interest.

DrawIt is a linked set of BASIC libraries for generating Draw files, written to aid Steve’s own understanding of the Draw format, Steve explains that it has a different approach to similar libraries, so might be worth a look.

The Longs BASIC library provides routines for handling long integers referenced by normal integer variables. All the standard integer keywords and operations are emulated and work with any combination of normal integer variables and expressions and long integers. Like the Strings library, it was written to explore a new idea for providing long integer support in Basalt, but that has not been fully written yet, so Steve is releasing the library because it may be of interest.

The Structs BASIC library provides routines for handling structures. It was written using some long-standing, but not (yet?) implemented, ideas for Basalt, because structures have been high on the list of things wanted in BASIC. It is not going to be fast, according to Steve, but it may be of interest anyway.

Prototypes of structures are defined, and new structures are created from them, or they can be applied to existing blocks of memory, such as window information.

Prototype variables catered for are:

  • integer%
    a 4-byte integer
  • string$
    a 5-byte SIB for a string
  • string$[n]
    a string in a buffer of length n+1, read as string$
  • string!
    an indirected external string, read as string$
  • byte?
    a 1-byte integer
  • float|
    a 5-byte floating point number
  • substr{proto}
    a substructure in the main structure
  • substr{}
    an indirected external substructure
  • array#(n)
    an array with n+1 elements; types: # = % $ ? | !
  • array(n){proto}
    an array of n+1 substructures
  • array#()
    an indirected external array; types: # = % $ |

Substructures can be nested and are referenced by name only:

  • Subproto=(FNcDEF{byte?,buffer$[15],external!})
  • Prototype=(FNcDEF{word%,string$,float|,substr(5){Subproto}})
  • struct=FNcNEW(Prototype)
  • PROCc{struct,substr(1),buffer$="Hello World"}
  • PRINT (FNc{struct,substr(1),buffer$})

Finally, version 1.30 of the Basalt module is available. The module provides BASIC with extra keywords that can be used just like the normal ones. It can be used with any version of the BASIC module and does not require any special installation. Since it’s original release in 2003, it has been completely re-written and greatly extended – but do note that this is an alpha version, and should not be put to serious use; It has been made available to invite comments and suggestions.