Return Multiple values from C++ Plugin


I found that we can return only one value/array back from the C++ DLL Plugin and am wanting to return multiple values from the Plugin ?

Let me know the best way to do it, given that I will be returning multiple values from the function.


You can use set variable function gSite.Setvariable()


I asked this question awhile back and got an answer on the old Yahoo AmiBroker DLL group. You need to join to view the thread.

Here is part of Tomasz’s reply:

“In principle you should pass local variables as ARGUMENTS to function call and return value by return call.

This is good programming practice as EXPLICIT pass of arguments makes code easy to read and understand.

If your DLL function secretly sneaks values behind scenes into variables it is simply bad design / bad practice making code unreadable and difficult to maintain.“

There is also this post the describes passing variables by name:


Thanks for the quick reply. How is the SetVariable accessed from AFL ?
Is there a certain way the variable is declared/accessed in AFL ?

I did SetVariable but all my values are zero in AFL.


in AFL if you have a variable name as “XY” then you can set this variable in plugin

gSite.SetVariable("XY", 100.00);


I believe you did not understand my question. I have set a variable in DLL using the SetVariable function but am unable to get/access the same variable from AFL. Say I want to print the value of this variable in AFL , is the following statement correct ?

gSite.SetVariable(“XY”, 100.00 );


global xy;
DLL_Function_Called(); // This set the value of the variable in DLL

So if i do this, I always get the value as zero. Is this the right way to access the variable from the DLL ?


you can see this.



Did you read the docs?

Obviously this is wrong. And the compiler in fact should warn you about this pretty much obvious type mismatch. Did you check the prototype of the function in Plugin.h file? It is

void		(*SetVariable) ( const char *pszName, AmiVar newValue );

So it takes name and AmiVar structure as second parameter. You are not passing AmiVar to SetVariable() and obviously you are calling SetVariable() incorrectly. Correct call is:

// This is C++ code, NOT AFL
AmiVar var;
var.type = VAR_FLOAT;
var.value = 100;

gSite.SetVariable( "xy", var );


I am sorry, just to explain you that I am not getting the value on the AFL side I ignored the syntax in explaining it to you.

I am sending in the AmiVar as the second parameter just as you mentioned in your post above to SetVariable and also the named variable (first variable) in parenthesis is in lower case.

This still isn’t giving me the desired results on the AFL side.

So what could be wrong ?


I found out my issue and the things presented by you are correct. Sorry for the inconvenience.