Passing dynamic array to DLL function fails

Questions about MultiCharts and user contributed studies.
JimC

Passing dynamic array to DLL function fails

Postby JimC » 11 Jul 2011

The following EL study (except for MessageLog call), which calls the FILLDYNARRAY function defined in TSKit documentation works when called from TS but not from MC 6.2. MC 6.2 causes error message "Error in study DllTest:: The parameter is incorrect".

external: "c:\windows\system32\EPTFuncLibMC.DLL", void,"FILLDYNARRAY", IEasyLanguageObject , LPSTR;


array: Levels[](0.0);

array_SetMaxIndex(Levels,10);

FILLDYNARRAY(self, "Levels");

MessageLog("DllTest ", date:6:0, "/", time:8:0, "/",Levels[0]:6:2);


Here is the c++ function

//////////////////////////////////////////////////////////////
// Fill dynamic EasyLanguage array
void __stdcall FILLDYNARRAY
(IEasyLanguageObject * pEL, char *PassedVar)
{

IEasyLanguageVariablePtr pMyVar = NULL;
IELFrameworkArrayPtr pDynArray = NULL;
IEasyLanguageDateTime * pMyDateTime = pEL->DateTimeMD[ dataDefault ] ;
double myDT = pMyDateTime->AsDateTime [0] ;
long nTotVars = pEL->VariablesCount;


for (long n = 0; n < nTotVars; n++)
{
pMyVar = pEL->Variables[n];

_bstr_t mybstr = pMyVar->Name;


if (pMyVar->DataType == dtHandle)
{

int nValue = pMyVar->GetAsInteger(0);
CComVariant xx(pEL->Close[0]);
if (pEL->System->Array->IsValidHandle( (int) nValue ) && (mybstr == (_bstr_t) PassedVar))
{
pDynArray = pEL->System->Array;
pDynArray->SetValue(nValue, 0, CComVariant(xx));
}

}

}

}


Anybody have any ideas on how to make this work.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Passing dynamic array to DLL function fails

Postby TJ » 11 Jul 2011

1. Please log in and use the main forum. This forum is for the DT version only.

2. Please use code tag when posting codes.


Return to “MultiCharts”