OpenersNotesSection(Spacer1)Details

After the call to WSPutFunction() other WSTP functions must be called to send the arguments of the function.

WSPutFunction() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSPutFunction() fails.

WSPutFunction() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

/* put an Integrate[] expression to a link */

void f(WSLINK lp)
{
	if(! WSPutFunction(lp, "Integrate", 2))
		{ /* unable to put the function to lp */ }

	if(! WSPutFunction(lp, "Times", 2))
		{ /* unable to put the function to lp */ }

	if(! WSPutFunction(lp, "Power", 2))
		{ /* unable to put the function to lp */ }

	if(! WSPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

	if( ! WSPutInteger(lp, 2))
		{ /* unable to put the integer to lp */ }

	if(! WSPutFunction(lp, "Power", 2))
		{ /* unable to put the function to lp */ }

	if(! WSPutFunction(lp, "Sqrt", 1))
		{ /* unable to put the function to lp */ }

	if(! WSPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

	if(! WSPutInteger(lp, -1))
		{ /* unable to put the integer to lp */ }

	if(! WSPutSymbol(lp, "x", 1))
		{ /* unable to put the symbol to lp */ }

	if(! WSEndPacket(lp))
		{ /* unable to send the end-of-packet sequence to lp */ }

	if(! WSFlush(lp))
		{ /* unable to flush any buffered output data in lp */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSPutString(), paclet:ref/c/WSPutString])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[C/C++ Language Interface, paclet:guide/CLanguageInterface])}, {▪(RefLinkPlain[Installable WSTP Programs, paclet:guide/InstallableWSTPPrograms])}, {▪(RefLinkPlain[WSTP API, paclet:guide/WSTPAPI])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Data, paclet:guide/WSTPCFunctionsForExchangingData])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Expressions, paclet:guide/WSTPCFunctionsForExchangingExpressions])}, {▪(RefLinkPlain[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}, {▪(RefLinkPlain[WSTP Expression Packet Handling, paclet:guide/WSTPExpressionPacketHandling])}})}})