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

[TRNSYS-users] C++ file names and labels in TRNSYS



Hi,
 
I have read some posts on passing file names or labels to C++ TRNSYS types but I don't think this question has been definitively answered.
 
This is what I have done:
 
In the TRNSYS.h file I have the following lines which map the fortran functions to C:

extern "C" __declspec(dllimport) char* _cdecl TRNSYSFUNCTIONS_mp_GETLUFILENAME(int* LU);
extern "C" __declspec(dllimport) char* _cdecl TRNSYSFUNCTIONS_mp_GETLABEL(int*, int*);
#define getLUfilename TRNSYSFUNCTIONS_mp_GETLUFILENAME
#define getLabel TRNSYSFUNCTIONS_mp_GETLABEL

Then in the type I have:

char *ss, *ss2; 
int LU=(int) par[0]; 
int iu=info[0];
int num=1;
ss=getLabel(&iu,&num);
ss2=getLUfilename(&LU);
FILE *log; fopen_s(&log,"log.dat","w");
fprintf(log,"\n%s\n%s",ss,ss2); fclose(log);

This code works (doesn't crash) but prints to the log file:
"Label not available"
"Cannot find a file associated with that logical unit"
 
I did link the file, logical unit and labels correctly in the proforma so that is not the problem.
 
Does anyone know what I am doing wrong?
 
Thanks,
 
Mark