<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.hl
        {mso-style-name:hl;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=FR link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi Xingbin,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If you just want to know the name of the file, you can use the
code example below. <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>(However, you will not be able to open that file during a TRNSYS
simulation, except if you use the new FILE keyword in Trnsys 17; in the other
cases, the file is opened by TRNSYS and thus locked).<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Werner<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span class=apple-style-span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:black'>#include
"TRNSYS.h" //TRNSYS acess functions (allow to acess TIME etc.)</span></span><span
class=apple-style-span><span lang=EN-US style='font-size:10.0pt;font-family:
"Courier New"'> <br>
<br>
<span style='color:black'>extern "C" __declspec(dllimport)
int     _cdecl TRNSYSFUNCTIONS_mp_GETEXTFILEPATH(int
*unitNum, int *fileNum, char* extFilePath);</span><br>
<br>
<span style='color:black'>#define getExtFilePath TRNSYSFUNCTIONS_mp_GETEXTFILEPATH<o:p></o:p></span></span></span></p>

<p class=MsoNormal><span class=apple-style-span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></span></p>

<p class=MsoNormal><span class=apple-style-span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:black'>…<o:p></o:p></span></span></p>

<p class=MsoNormal><span class=apple-style-span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></span></p>

<p class=MsoNormal><span class=apple-style-span><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:black'>//   
DO ALL THE VERY FIRST CALL OF THE SIMULATION MANIPULATIONS HERE</span></span><span
class=apple-style-span><span lang=EN-US style='font-size:10.0pt;font-family:
"Courier New"'><br>
<br>
<span style='color:black'>if (info[6]== -1) // first call of this component in
the simulation</span><br>
<br>
<span style='color:black'>{</span><br>
<br>
<span style='color:black'> </span><br>
<br>
<span style='color:black'>    // open external file and compute
sum<br>
<br>
       const int
maxPathLength     
=       300; //  ! Maximum length of
variables containing path- and filenames<br>
<br>
                                                
// (adapt this number if it has been changed in TrnsysConstants.f90,<br>
<br>
                                                
// or FORTRAN will screw up the stack)<br>
<br>
       int fileNameLength=-1;<br>
<br>
       char name[maxPathLength];<br>
<br>
       int fileNumber = 1; // use first FILE
attached to this type<br>
<br>
       <br>
<br>
       fileNameLength =
getExtFilePath(&iunit, &fileNumber, name);<br>
</span><br>
<span style='color:black'>      
name[fileNameLength] = 0x0; //</span> FORTRAN <span style='color:
black'>doesn't use end-of-</span>string <span style='color:black'>marks</span></span></span><span
lang=EN-US style='font-family:"Arial","sans-serif";color:black'><br>
<br>
</span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> xingbin lin
[mailto:lynxingbin@gmail.com] <br>
<b>Envoyé :</b> samedi 5 juin 2010 08:39<br>
<b>À :</b> keilholz, werner<br>
<b>Cc :</b> TRNSYS-users@cae.wisc.edu<br>
<b>Objet :</b> Re: [TRNSYS-users] Call external file through special cards
with C++<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<div>

<p class=MsoNormal>Dear <span style='font-size:11.0pt;color:#1F497D'>Werner:</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='color:#1F497D'>Thank you for your help so
much,Your solution is that to provide a dll which is programmed by fortran,then
I can build a C++ class to read the file content according to the logical unit
number,this is very smart.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='color:#1F497D'>However,what I just want to get
the file path which is assigned in the specail cards in the new type.That is to
say,I would like to get the path of the file in my type,not the content.</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='color:#1F497D'>Can you provide me more advices?
Thanks a lot!</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='color:#1F497D'>Xingbin
Lin</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>2010/6/4 keilholz, werner <<a
href="mailto:werner.keilholz@cstb.fr">werner.keilholz@cstb.fr</a>><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'>Hi Xingbin,</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;color:#1F497D'>I once proposed this
solution :</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><a
href="https://www-old.cae.wisc.edu/pipermail/trnsys-users/2010/005500.html"
target="_blank"><span lang=EN-US>https://www-old.cae.wisc.edu/pipermail/trnsys-users/2010/005500.html</span></a><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'>It does not use the special cards, but
the external file tab, like FORTRAN components. </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;color:#1F497D'>In TRNSYS 17, there is a
special FILE keyword, which solves this problem. I attach a sample component
with source code using it (but this requires Trnsys 17, does not work with 16).</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'>Werner</span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
style='font-size:10.0pt'>De :</span></b><span style='font-size:10.0pt'>
xingbin lin [mailto:<a href="mailto:lynxingbin@gmail.com" target="_blank">lynxingbin@gmail.com</a>]
<br>
<b>Envoyé :</b> vendredi 4 juin 2010 15:31<br>
<b>À :</b> <a href="mailto:TRNSYS-users@cae.wisc.edu" target="_blank">TRNSYS-users@cae.wisc.edu</a><br>
<b>Objet :</b> [TRNSYS-users] Call external file through special cards
with C++</span><o:p></o:p></p>

</div>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hello
everyone,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I
built a new type in which I need call external file through special
cards in trnsys 16,and I exported it as C++,in this type,I wanted to
get the path of external file by using the access  function
getLabel(int,int) which was defined in TRNSYS.h header file.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>But
when I runned the simulation,it  prompted "Access  violation at
address ###### in module 'dforrt.dll'".The function
getLabel(int,int)  defined in "TRNSYS.h" is that "extern
"C" __declspec(dllimport) char* _cdecl 
TRNSYSFUNCTIONS_mp_GETLABEL(int , int );#define
getLabel       TRNSYSFUNCTIONS_mp_GETLABEL".<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I
searched this problem in internet,somebody said maybe the reason existed in the
process of calling the dll between  C++ and Fortran. <br>
Please tell me how can I solve this exception and any suggestions.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thanks.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Xingbin
Lin <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p>

</div>

</div>

</div>

</div>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

</div>

</body>

</html>