question

Lucas Klein avatar image
0 Likes"
Lucas Klein asked Lucas Klein commented

DLL function called by FlexSim and code

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.

thanks in advance.

FlexSim 19.1.0
dll makerfactorialrecursive
report5.jpg (22.1 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
1 Like"
Phil BoBo answered Lucas Klein commented
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));
}
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Lucas Klein avatar image Lucas Klein commented ·

Thanks @phil.bobo this will help a lot

0 Likes 0 ·