Hello, You can not re-use the same array if you call-back AFL functions because of reference counting that AFL uses to avoid unnecessary copying of arrays when passing arguments to functions or assigning variables. AFL does not copy what you pass to CallFunction, instead uses a pointer. Copy of array is only created when creating new variable as a result of arithmetic operation or return value from the function.
So you should use gSite.Alloc(), write values to array, call CallFunction and you can call gSite.Free and repeat that as many times as there are plots. If you forget to call Free AmiBroker will call it by itself automatically after AFL formula execution is completed. Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: "ccr1der" <[email protected]> To: <[email protected]> Sent: Friday, February 20, 2009 9:18 PM Subject: [amibroker] Help needed calling plot from C++ .dll - redundant plots > I'm 2 inches away from the end of my drive to crazy. > > I have 2 embedded loops in C++. In the inside the loop (i), I define > args[0].array[i]=somefloatvals*j; //where j = outside loop val > After that, I have a call to Plot that works fine as far as syntax is > concerned: Plot = gSite.CallFunction("Plot", 7, args ); > > All of the other args [numbers 1-6] are previously defined above the > nested loops. I simply want to be able to redefine args[0].array as > many times as j, and plot as many unique lines as j. > > The issue I'm having is, every plot turns out the same. It's as if > once args[0].array has been defined, it cannot be defined again. I'm > getting as many plots as j, but they're identical. If I create whole > new sets of args for each plot (i.e. args1[0].array, args2[0].array, > etc.), I get unique lines. > > Also, what is the function gSite.Free, how is it used? I cannot find > a single example of this anywhere. A little bit of talk about it, but > that's all I can find. > > Any help would be greatly appreciated. > > -Dan > > > > > ------------------------------------ > > **** 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/ > > Yahoo! Groups Links > > >
