home products news downloads documentation support gallery online maps resellers search
TNTmips

HOME

PROFESSIONAL
  TNTmips
  TNTedit
  TNTview
  TNTsdk
  Prices
  How To Order

CONTACT MI
  Resellers
  Consultants
  MicroImages
  About MI
  Visiting
  Prices
  Send Email
  Reseller Resources

SHOWROOM
  Gallery
  Technical Guides
  New Features
  Testimonials
  Reviews
  World Languages

FREE PRODUCTS
  TNTmips Free
  TNTatlas

  MI/X
  FAQ

DOCUMENTATION

SCRIPTING

SITE MAP


smlplug.c


/////////////////////////////////////////////////////////////////////////////
//
//		Sample SML Plugin module.  
//	
//		To install, create a directory called "plugins" in the folder
//		containing the TNTmips executables, dll, reference files.
//		Use the makefile.n that came with this sample to create a dll.
//		Copy that dll into the "plugins" directory.
//		SML will actually look for the plugins directory using the same 
//		method it uses	to find reference files, so on NT, you can place 
//		it in your home directory.
//
//		Note that if you call anything else from the TNTsdk, you may
//		have to modify the makefile.n to link in more libraries. 
//		


#include <mi32/sml.h>

/////////////////////////////////////////////////////////////////////////////
//		Define your functions here
/////////////////////////////////////////////////////////////////////////////
// All SML Functions get the same 4 arguments:
// 
//	int numargs,			Guarenteed to be at least the number of parms
//								you specified in your parm list.  You can ignore
//								it unless you have PARM_Optional parameters, 
//								which must always be at the end of the list.
//								Also, if the last parameter in your list is
//								named "...", the caller can pass any number
//								of parameters from that point on.
//
//	SMLARG* args,			The list of parametere
//
//	UINT8* argtype,		The STYPE_Xxxx of each parameter.  Will always
//								be what you specified in the parm list, unless
//								you specified STYPE_AnyVal, you will be passed
//								either an STYPE_Constant or STYPE_String
//
//	SMLCONTEXT* context	The SMLCONTEXT for the currently running script
//

// Define the parameters for the function.
static SMLPARM DemoFunc_Parms[] = {
//   Name   	STYPE		   	flags  Description		
	{ "x", 		STYPE_Constant, 	0, 	"Description of this parameter"},
	{ NULL }			// Indicates end of list
	};

#define DemoFunc_CreateDate	19990916		// Function added on 16 Sep 1999
#define DemoFunc_ModDate		19990916		// Function modified on 16 Sep 1999
#define DemoFunc_FuncType		STYPE_BFunction		
#define DemoFunc_Desc			"This is a demonstaration of how to add a function via a plugin"


static double DemoFunc (
	int numargs,
	SMLARG* args,
	UINT8* argtype,
	SMLCONTEXT* context
	) {
	return(args[0].val);	// Doesn't do much.  It's just a demo.
	}

//-----------------------------------------------------------------------


// Define the parameters for the function.
static SMLPARM DemoStringFunc_Parms[] = {
//   Name   	STYPE		   	flags  Description		
	{ "str$", 		STYPE_String, 	0, 	"Description of this parameter"},
	{ NULL }			// Indicates end of list
	};

#define DemoStringFunc_CreateDate	20021023		// Function added on 23 Oct 2002
#define DemoStringFunc_ModDate		20021023		// Function modified on 23 Oct 2002
#define DemoStringFunc_FuncType		STYPE_BSFunction		// Function return string
#define DemoStringFunc_Desc			"Demo function taking and returning a string"


static SMLSTRING* DemoStringFunc (
	int numargs,
	SMLARG* args,
	UINT8* argtype,
	SMLCONTEXT* context
	) {
	MISTRING str(*args[0].str);

	MISTRING mistr;
	mistr << "You can do a lot with a string" << str << "\n";

	return(context->StringAlloc(mistr));
	}




/////////////////////////////////////////////////////////////////////////////
//		List of functions to install
/////////////////////////////////////////////////////////////////////////////

static SMLFUNC FuncList[] = {
	SMLFUNCDEF2(DemoFunc),
	SMLFUNCDEF2(DemoStringFunc),
	{ NULL }		// Indicates end of list
	};


/////////////////////////////////////////////////////////////////////////////
//		These are the only functions exported from the DLL.  
//		(The export directive is in sml.h.  The makefile.n
//		should define SMLPLUGINDLL
//		SMLPluginInit will be called when an SMLCONTEXT is being
//		created and SMLPluginStop will be called when an
//		SMLCONTEXT is being destrioied
/////////////////////////////////////////////////////////////////////////////

int SMLPluginInit (
	SMLCONTEXT* context
	) {
	// Install our list of functions so that they will show up in a group
	//	named "Sample Plugin".  You can name it whatever you want.
	context->InstallFunctions("Sample Plugin", FuncList);
	return(0);
	}


int SMLPluginStop (
	SMLCONTEXT* context
	) {
	// Do any cleanup you may need to do here.
	return(0);
	}


Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11