[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TRNSYS-users] Reading data from external file using C++
Knut Erik,
I believe that you may have to hard code the name of the external file
that you want to open in the C++ code. I am no expert in writing C++
Types but I have been told that it is very hard to pass text back and
forth between a fortran and a C++ dll because the two languages handle
strings very differently. I do not believe that anyone has found a way
to declare a C++ string variable that will manage to understand the
Fortran character string that carries the result of the getLUFileName()
function. I would be happy for someone to correct me if I am wrong about
this!
Cheers,
David
Technical Support Team
Thermal Energy System Specialists, LLC
2916 Marketplace Dr, Suite 104
Madison, WI 53719
techsupport@tess-inc.com
>----- Original Message -----
Subject: [TRNSYS-users] Reading data from external file using C++
Date: Fri, April 18, 2008 8:10
From: knut.erik.enerstvedt@niva.no
> 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
>
>
> _______________________________________________
> TRNSYS-users mailing list
> TRNSYS-users@engr.wisc.edu
> https://www.cae.wisc.edu/mailman/listinfo/trnsys-users
>
>
>