Hi Tomasz,
I just made the code change and configured VS to use "precise" for float instead of "fast". These changes made no difference. The plugin function is just doing divide-by-zero protection and there is no other plugin code exposed to AmiBroker. The code changes I made were to immediately copy all float * values returned by AmiBroker functions to a class with an embedded compile-time array, and do all processing on that class before copying values back to AmiBroker. Other than copy-to and copy-from operations, the code never touches an AB float *. It is the only plugin code exposed to AmiBroker at all and a small enough code segment to easily watch.
It's weird the plugin is returning correct results but AmiBroker becomes flakey. What's more mysterious, the plugin passes unit tests -- it returns stable, correct results when called on its own, even in a loop. It is AmiBroker AFL which starts giving unstable results when I pass results around during more intense processing. Are you sure there can't be a compiler or pragma-type issue I need to address? It's so bizarre, if it's not a pointer issue, it makes me think something basic is incompatible between AmiBroker and the DLL.
BTW, I'm using the sample.dll files and haven't touched plugin.h, plugin.cpp, sample.h or sample.cpp. I have noticed VS is giving a bunch of "function definition not found" messages on a group of PLUGINAPI prototypes in the plugin.h file. I assume this is normal?
Just as an FYI, the code for my exposed function is below. There's a preceding two-argument function which just catches the call from AmiBroker and passes the arguments from the ArgsTable along to this function. It's just a safe division routine, which gives the user an option to specify the value to substitute for zero and a value to use if both numerator and denominator are zero. It's not rocket science. In fact, it's so simple I can do the whole thing as a series of constructor calls.
The first two float * arguments to it come from the ArgsTable passed by AmiBroker and are immediately copied to the class I mentioned, which wraps an embedded array. Similarly with the float * returned by calls to AlmostEqual and IIF. After it returns result, the receiving class copies its contents to an AmiVar and sends it off to AB. Those are all the operations with pointers being done.
ABArray SafeDiv(float *num, float *denom, float safeDenom, float numZero) {
//
// Exchange zeros for small number before dividing
//
ABArray
numm(num),
denomm(denom),
nZero(ab_AlmostEqual(numm, 0.0f)),
dZero(ab_AlmostEqual(denomm, 0.0f)),
dblZero(ab_And(nZero, dZero)),
safeD(ab_IIF(dZero, safeDenom, denomm)),
result(ab_IIF(dblZero, numZero, ab_Divide(numm, safeD)));
return result;
} // End SafeDiv
__._,_.___
Posted by: rosenberggregg@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (8) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? The Yahoo Mail app is fast, beautiful and intuitive. Try it today!
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
.
__,_._,___
EmoticonEmoticon