Example

	/* C program to call MUMPS */
	#include <descrip.h>
	#include <ssdef.h>
	#define $DYNDESCRIP(name) struct dsc$descriptor_d name = \
	{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0 }
	tomumps()
	{
	int status;
	$DESCRIPTOR(delim,"|");
	$DESCRIPTOR(startpiece,"3");
	$DESCRIPTOR(endpiece,"4");
	$DYNDESCRIP(ret);
	$DESCRIPTOR(replace,"Raiders of the Lost Ark|1982");
	$DESCRIPTOR(rec,"G Lucas|Lucas Enterprise|Star Wars|1978|PG");
	lib$put_output(&rec);
	status = REPLACE(&ret, &rec, &delim, &startpiece, &endpiece, &replace);
	if (status == SS$_NORMAL)
	lib$put_output(&ret);
	lib$sfree1_dd(&ret);
	return status;
	}	
	

This C program invokes REPLACE using ret to hold the returned value; rec,delimiter, startpiece, and endpiece to hold the arguments to the $PIECE construct; and replace to hold the replacement value.

The following macro declares the connection between REPLACE and SETPIECE^FROMC and specifies that the M routine returns a value.

When assembling the macro on an Alpha VMS system, use the /ALPHA qualifier immediately after the command to invoke the Alpha Macro-64 assembler. If the module contains only glue code MACROs and no actual AXP machine instructions, MACRO /MIGRATE also works.

	.title CMTAB.MAR - sample of C call to MUMPS
	.library "gtm$dist:gtmzcall.mlb"
	mumps_binding entryref=SETPIECE^FROMC,linkname=
	REPLACE, output=yes
	.end	
	

The following M program returns the value of a SET $PIECE with values supplied by the caller.

	FROMC;sample called from a C program to 
	;perform a set piece
	;
	SETPIECE(rec,delimiter,stpiece,endpiece,value)
	set $p(rec,delimiter,stpiece,endpiece)=value
	quit rec