|
How AppBasic works
Shell applications
AppBasic applications have source code from which the final application is produced. The AppBasic source - known as a shell - always runs in exactly the same way as the finished application but requires the presence of AppBasic. Finished applications are completely freestanding.
Programs
The distinguishing feature of shell applications is that !RunImage is a directory instead of a single file. The totality of BASIC files placed in !RunImage are regarded as the application's program and are BASIC procedure libraries which describe what the application should do about those desktop events the application wishes to ‘handle’ (respond to). This is achieved by placing definitions of special procedures known as event handlers in !RunImage.
For example, to convert the demo-application MinApp (from the C/C++ package) to BASIC all that is required is to create a !RunImage directory inside which is placed a BASIC file containing the definition
DEF PROCDealWith_MenuEvent(event,object,component)
IF event=1 THEN FINISHED=TRUE
ENDPROC
|
BASIC version of MinApp
|
Compression
Compression, for an AppBasic application, is analogous to 'C' compilation and is how the various (BASIC) files, which make up the source code, are synthesised into one !RunImage file with all extraneous material removed (e.g. unused procedure definitons, variables etc). Finished results are very efficient.
AppBasic shells are compressed via the menu which is popped up by dragging the application onto !AppBasic's iconbar icon (keypress alternative: double-click the application while holding down the Ctrl key).
A note on efficiency
Using AppBasic costs virtually zero in the way of overheads. When an application is compressed AppBasic examines the contents of !RunImage and writes an event-polling routine which reflects the events which are handled. This, together with initialisation, is the only code contributed. It amounts, at most, to a few hundred bytes and is what would have to have been written anyway (if AppBasic had not been used). For example, the BASIC version of MinApp described above compresses to a !RunImage file of 582 bytes, whereas the 'C' original is 4,383 bytes!
|
|