DLL function called by FlexSim and code

DLL function called by FlexSim and code

lucas_klein
Not applicable
7 Views
2 Replies
Message 1 of 3

DLL function called by FlexSim and code

lucas_klein
Not applicable

[ FlexSim 19.1.0 ]

Dear all,

I am trying to build a recursive DLL function. I'd like to start it using FlexSim but as a recursive function, it must be called by itself along the code.

How can i set the statments to the function to make it works by both calls? Since it's using (FLEXSIMINTERFACE) as main statement I can't declare any arguments.

19381-report5.jpg

thanks in advance.

0 Likes
Accepted solutions (1)
8 Views
2 Replies
Replies (2)
Message 2 of 3

philboboADSK
Autodesk
Autodesk
Accepted solution
double factorial_recursive(int n)
{
	if (n == 1 || n == 0)
		return 1;
	return factorial_recursive(n);
}
visible double factorial(FLEXSIMINTERFACE)
{
	return factorial_recursive(param(1));
}

If you care about the function name and want to use it elsewhere in your dll, give the nice function name to the recursive function instead of the function that links the DLL node to the DLL code:

double myFactorial(int n)
{
	if (n == 1 || n == 0)
		return 1;
	return myFactorial(n);
}

visible double factorialFunction(FLEXSIMINTERFACE)
{
	return myFactorial(param(1));
}


Phil BoBo
Sr. Manager, Software Development
Message 3 of 3

lucas_klein
Not applicable

Thanks @phil.bobo this will help a lot

0 Likes