Introduction to BareED's DAC-port:


You cannot imagine how many system crashes I have faced until I solved a bug causing a completely frozen machine...
Every time when now the scrolling stops because I have released the cursor-key by accident my heart misses a beat...



Anyway,  the DAC-port of BareED is needed to provide stuff that isn't there from house, for example printing and syntax-highlighting.

A DAC-application (plug-in) is ever started by the user - and is fired up by BareED. Whether the user selects the corresponding menu-item of this DAC-application or manually invokes it doesn't make any difference.

Your written DAC-application is an ordinary AMIGA-DOS program - with no concession to the data or code layout.
Important is only that you fetch the supplied message - and this is normally and automatically done by the used startup-code comming with your compiler and assembler!
To clarify this: If you can write applications that are able to be fired up by Workbench (double click on the icon) then you are also able to write DAC-applications - since the underlaying mechanism is truely the same!

Example:

/* ----------- Program start... ------------ */

#include <workbench/startup.h>

#include <string.h>

#include <bareed/bareed.h>

/*
Normally, you retrieve the WBenchMsg in argv[0] when argc is zero!
But, any startup-code compatible to "rstartup" provides also the
WBenchMsg variable.
*/
extern struct WBStartup *WBenchMsg;

/*
NOTE:
Some compilers don't set up "WBenchMsg" instead they use "_WBenchMsg",
so, for these compilers you have to use this instead:
*/
extern struct WBStartup *_WBenchMsg;
#define WBenchMsg _WBenchMsg

/*
Declared as global...
The WBenchMsg and the message BareED sent are almost identical...
BareED only extents these messages
*/

struct PseudoMsg *PsMsg;


int main( int argc, char **argv)
{
    
ULONG version;

    
/* Discover if we have been launched by Workbench */
    
if ( !WBenchMsg)
        
return 20;

    
/* Either from Workbench or BareED */
    
if (strcmp( WBenchMsg->sm_Message.mn_Node.ln_Name, "BAREED"))
        
return 20;

    
/* Was BareED. Remember extended WBench-message */
    
PsMsg = (struct PseudoMsg *) WBenchMsg;

    
/* Older versions of BareED did not support pm_GetAttr()... */
    
if ( !PsMsg->pm_GetAttr)
        
return 20;

    
/* Get the version of BareED's DAC-port */
    
PsMsg->pm_GetAttr( DAC_VERSION, &version, TAG_END);
    
if (version < 6)
        
return 5;

    PsMsg->Tell( "
Gotcha! Utilizing BareED's DAC-port");

    
return 0;
}


That's all. As you can see from the fragment shown above it's not difficult to prepare a normal program to be used as a DAC-application.

As long as your retrieved message is not sent back to BareED (replied), BareED will refuse to quit. So, what to do in order to reply the message?
Simply, end your program (DAC-application) as usually with a "return" statement - then, your used startup-code returns this encountered message to BareED and BareED knows that this DAC-application does not need anymore to be attached to him.