TaskCheck 0.02
=========

Running TaskCheck without any parameters, say by double-clicking on it, now gives a message giving the version and syntax.

Syntax: TaskCheck <taskname> [<command>]

TaskCheck can be used in two ways:

1.      It can, given a taskname, prevent a second instantiation of that task being run by causing an error box to halt the script.

Thus, for my application Pic_Index, the lines in the Run file:

        |  Check if already running
        Run <Obey$Dir>.TaskCheck Pic_Index

halts the Run file execution with the error "Pic_Index is already running" in a WIMP error box if the task is already running.

The taskname should be exactly as appears in the TaskManager Tasks display, unless the taskname is more than a single word, in which case the taskname should be enclosed in quotes.

For example, the taskname for CDROMFS is CDROMFS Filer - therefore the line to add to the Run file would be:

        Run <CDROMFS$Dir>.TaskCheck "CDROMFS Filer"

for this version of TaskCheck.

The place to add such a line would be usually after the IconSprites line and the line setting the applications ...$Dir variable.

NB The taskname of FireWks contains a hard space, and thus should not have quotes around it.


2.      The second use of TaskCheck is to execute a command if the specified task is NOT running.  The command takes the form of an additional parameter.

So this can, for instance, ensure a subsidiary but essential task is running - a bit like RMEnsure does for modules!

As an example, I have an application to allow me to mute my USB radio using my TV remote control and Glenn Richards' IRMan application and the appropriate IR detector.

His IRManager task needs to be running for my app (IRDetect) to work, but accidentally attempting to load a second instantiation of it messes up the serial driver - a situation devoutly to be avoided!

The Run file of my app is as follows:

        Set IRDetect$Dir <Obey$Dir>
        IconSprites <IRDetect$Dir>.!Sprites
        RMReinit BlockDriver
        <IRDetect$Dir>.TaskCheck IRManager Filer_Run <IRDetect$Dir>.IRMan
        <IRDetect$Dir>.TaskCheck IRDetect
        WimpSlot -min 16k -max 16k
        Run <IRDetect$Dir>.!RunImage

Line 3 reinitialises the serial block driver as a precaution, then the next line Filer_Runs the IRMan application only if the task is not running already.

The line following prevents a second copy of my app IRDetect being run, if it is already running as a task, by throwing up the error box as described at the start of this file.

The error does not happen with the previous line because the presence of the extra parameter suppresses that behaviour.

The application TaskCheck is written in BASIC and has been compressed to a slim 764 bytes.

