I'm leveraging the calc engine to handle customizing calculations. The problem is that I have an object from which all calculations need to originate. I haven't been able to figure out a way to access this object either in a custom function or as a NamedReference. I've placed the information I need in the container for the calc manager, but I can't figure out how to get to it. If only the custom functions had access to the calc manager.
Can you shed any light on this?
Thanks
I'm afraid I do not understand your question. What are you trying to do?
I'll get a little more specific. I write mortgage software. We have a "loan object" that contains many pieces of information such as loan amount, loan term, APR, etc. I'm allowing my customers to create "data elements" by picking them from the loan object and then creating formulas based on these elements. As you may surmise, I need this loan object to perform my calculations. However, I can't figure out how to get my custom functions that I've added to the calc manager to pick up these elements directly from the loan.
I thought about making the current loan object a static variable, but they may have multiple loans open at the same time. How can I pass an arbitrary object to a custom function or get an arbitrary object from a custom function? When I tried to pass it in, I got the invalid parameter (Value) error.
If there were some way to get to the container of the calc engine from the custom function, that would work, but I haven't found that either. Does that make sense?
Yeah, I came to that conclusion myself and had to work around it. I now have a static integer dictionary of my active objects with a NamedReference that returns the ID of the current object. Once I have that ID in the formula, I can get the desired object easily from within any formula. It wasn't my favorite way to handle it, but it works.
Oh, yes, and I am making heavy use of the NamedReferences with these items. I've gotta say, your calc manager rocks! It's very easy to set this stuff up and make heavy use of it.
Thanks for your time!
Hi,
Yes, I think I understand, now. But I don't think what you are trying to do is possible. In order to use a reference in a formula, the CalcManager needs an UltraCalcReference.
If your loan object was a control or component on the form itself, the the CalcManager would handle this for you. Since it is not, you would need to implement your own calc references, which is not a trivial task and it's certainly not something I could explain here in a forum post.
I think your best bet would be to use a NamedReference for each value you need. So for example, you could create a NamedReference and give it a name that corresponds to some ID field of the loan and combine that with the property of the loan (like the amount). Then you would have to update the NamedReference value any time the loan amount changed and vice versa. Basically, you would use the NamedReference as a sort of intermediary.