TNTmips

HOME

FREE PRODUCTS
  TNTlite
  TNTatlas
  TNTsim3D

DOWNLOADS
  Release Version
  Development Version
  FTP
  Language Kits
  Sample Geodata
  Reseller Resources
  Promotional

DOCUMENTATION
  Tutorials
  Technical Guides
  Quick Guides

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. 2008 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

29 August 2008

page update: 13 Jun 07