It is from the specifications Mark wrote on the Specs and utils tab from the community.
Example
-------
Ok, here's a little C++ example, as it would appear in VisualC.
First, we write the DLL:
//demo.dll
//
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall
//returns a float and has 6 float parameters
BBDECL float BBCALL VecDistance( float x1,float y1,float z1,float x2,float y2,float z2 ){
float dx=x1-x2,dy=y1-y2,dz=z1-z2;
return sqrtf( dx*dx+dy*dy+dz*dz );
}
//returns a string and has one string parameter
BBDECL const char * BBCALL ShuffleString( const char *str ){
static char *_buf;
int sz=strlen(str);
delete[] _buf;
_buf=new char[ sz+1 ];
strcpy( _buf,str );
for( int k=0;k<sz;++k ){
int n=rand()%sz;
int t=_buf[k];_buf[k]=_buf[n];_buf[n]=t;
}
return _buf;
}
After building this, the resultant 'demo.dll' should be placed in the userlibs directory.
Now, we also need to create a 'demo.decls' file, describing the functions in our dll. This file
is also placed in the userlibs directory:
.lib "demo.dll"
VecDistance#( x1#,y1#,z1#,x2#,y2#,z2# ):"_VecDistance@24"
ShuffleString$( str$ ):"_ShuffleString@4"
...Voila! The next time Blitz is started up, the new commands appear within the IDE and can be used.
|