Plug-In

Main
Guide
What's new
Products
Downloads
FAQ
Mailing List
Links
[AU 200th Issue CD-ROM] Jaffa Software

WimpWorks Extension Modules


Introduction

WimpWorks Extension Modules (WEMs) are application directories which contain software plugins which can be compiled into a WimpWorks application.

These components are written in standard BBC BASIC (and can take advantage of any WimpWorks commands present - even in other WEMs) and add new commands and/or events to WimpWorks applications to take advantage of new ideas, protocols or to simply add a command which is felt is needed.

WEMs are installed by copying them into !WimpWorks.Resources.WEMs.


Format of a WEM

A WEM consists of (at least) four files inside an application (a directory beginning with an exclamation mark - '!').

The files are listed below and will then be explained in detail:

  • !Run (Obey)
  • !RunImage (BASIC)
  • !Sprites (Sprite)
  • Desc (Text)

!Run

This file is technically optional, however it should be present so that if the WEM is double clicked in a directory display (accidentally or on purpose) the user does not get an error message.

It is recommended that the file starts WimpWorks if it can, otherwise simply do nothing:


| !Run file for !Test, a WWv2 WEM
| © Jaffa Software 1998. All rights reserved.

IconSprites <Obey$Dir>.!Sprites
If "<WimpWorks$Dir>"<>"" Then Run <WimpWorks$Dir>.!Run %*0

!RunImage

This file is the BASIC file which will be linked into the WimpWorks application if the WEM is chosen to be included. This file has a relatively rigidly defined structure which must be adhered to. It also contains the actual code of all the new WimpWorks commands.

The file contains, in addition to the code for any new commands, four functions which must be present, all are prefixed with the name of the WEM (see later) and must all return zero (0).

In a WEM named test the functions would be:

  • FNtest_init - Called when the application is run, and guaranteed to be called exactly once.

  • FNtest_pre(wimp%, action%) - Called before the WimpWorks core library processes the Wimp_Poll call. wimp% is a pointer to the 256-byte block passed in R1 to Wimp_Poll. action% is a pointer to the reason code returned in R0 and can be accessed with !action%. These pointers allow you to modify the appearance of Wimp_Poll to WimpWorks.

  • FNtest_post(wimp%, action%) - Similar to ..._pre, however is called after the WimpWorks core library has processed the event.

  • FNtest_exit - Called when the application is about to exit. This is called before Wimp_CloseDown and should be used to close any files opened etc.

The rest of the file is left to zero or more procedures and/or functions which define the code for any new WimpWorks commands. Any WimpWorks command (whether core or provided by another WEM (which must also be included)) can be called, however they must be called in lowercase and prefixed with either PROC or FN, eg. OPENWINDOW(main) would be called as PROCopenwindow(main) and TASKINFO(&01) as FNtaskinfo(&01).


!Sprites

As with !Run this file is technically optional, however should be defined so that your WEM appears with an attractive icon.


Desc

This text file instructs WimpWorks how to process the WEM, data is held within a DEF WEMname...ENDWEM structure and anything outside such a structure is ignored.

The various WEM structures which must be implemented are:

DEF WEMdetails
    Name         test
    Description  Test WEM
    Author       (c) Jaffa Software 1998
    Version      1.00 (21-Feb-1998)
    Type         2
ENDWEM

  • Name - Used for prefix in the functions above

  • Description - A more verbose description used in the "WEMs to include" menu

  • Author - An author and copyright string as found in "About this program" boxes

  • Version - A version string as also found in "About this program" boxes

  • Type - This should be two in all third-party WEMs, other values are reserved for future expansion
DEF WEMevents
    Mode changed
        VAL(eva$), VAL(evb$)
        old_mode%, new_mode%
    Writable clicked
        VAL(eva$), VAL(evb$), evc$
        window%, icon%, text$
ENDWEM

Each new event consists of three lines: the first contains the name of the event (as it should be included in the "Respond to" menu (events expecting a value to be returned should have (FN) as the last four characters on this line)). The second line is the decode string, this is used to convert the three string paramets passed to jaffa_event into non-string values if necessary. The final line is the default parameter set which is appended to the definition of a subroutine when it is associated with the event.

Events which are unattached always return TRUE (-1). To initiate an event call PROCjaffa_event(event, eva$, evb$, evc$) or return%=FNjaffa_event(...).

event is an integer representation of the event and is the result returned from ENCODE when applied to the name of the event. This could be defined in FNname_init, eg. myEvnt%=FNencode("Mode changed") or calculated using !EncodeStr.

DEF WEMcommands
    BEEP        PROC
        <length>
        Make a beep for <length> seconds, this is a
        command which is a bit silly.
        ENDHELP
    BOOLEAN     FN

        Returns a random boolean value (TRUE or FALSE).
        ENDHELP
ENDWEM

Within this block is a list of the commands added, followed by an amount of whitespace and their type: PROC or FN. Following this is the syntax line which is appended to the command in the online help window. The syntax line must be blank if there are no parameters.

Finally, there is a block of text defining the online help itself for the command, this is practically unlimited, but the TRIMmed length of the line should be <= 45 characters, so that it can fit into the width of the online help window. After the text is defined, there is an ENDHELP command, followed by zero or more other command definitions.


Conclusion

This is a complete specification of WEMs as they are implemented in the current version of WimpWorks, any questions can be directed to the email address at the bottom of the page or the mailing list.


© Jaffa Software 1998.
Last modified: Wed Aug 5 10:26:37 BST 1998 (Now uses MML)