[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[TRNSYS-users] Reading data from external file using C++



Dear TRNSYS users,

I have created a new Type using C++, and in this Type I wish to read data
from an external file with the possibility of setting the filename in the
studio Proforma. To do this, I have added a logical unit parameter and
assigned this to the filename in the Proforma. In the source code, I plan
to retrieve the filename by using

const char* filename = getLUfileName(LU);

where LU is the logical unit number. According to the manual, there should
be a function called getLUfileName in the TrnsysFunctions module which
returns the filename associated with a logical unit number. To be able to
use it, I have declared the following in the "TRNSYS.h" file:

extern "C" __declspec(dllimport) char*    _cdecl
TRNSYSFUNCTIONS_mp_GETLUFILENAME(int);
#define getLUfileName                   TRNSYSFUNCTIONS_mp_GETLUFILENAME

 This compiles without errors, but when I try to run the TRNSYS simulation,
I get the following error message:

Access violation at address 032AF871 in module 'DFORRT.DLL'. Write of
address 00000029.

and the simulation aborts.

Does anyone know what is causing this, and if not, is there any other
clever way of retrieving the filename when I am using C++?


Kind regards,
Knut Erik Enerstvedt



----------------------------------------------------------------------------------------------------------------------
NIVAs hovedkontor har flyttet til nye lokaler i CIENS - Forskningssenter
for miljø og samfunn; Gaustadalléen 21, 0349 Oslo. Meld deg på vårt
nyhetsbrev på www.niva.no