<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:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="date"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:sans-serif;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:2064475144;
mso-list-type:hybrid;
mso-list-template-ids:-533571574 67895311 67895321 67895323 67895311 67895321 67895323 67895311 67895321 67895323;}
@list l0:level1
{mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
</style>
</head>
<body lang=FR link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Hi,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Using return values from
functions defined in FORTRAN is problematic, due to the different stack model
between the 2 languages. I solved the problem like this:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<ol style='margin-top:0cm' start=1 type=1>
<li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:
Arial'>Define a new function in TRNDll (basically a copy of the existing
one, adapted as SUBROUTINE):<o:p></o:p></span></font></li>
</ol>
<p class=MsoNormal style='margin-left:18.0pt'><font size=2 color=navy
face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'>SUBROUTINE
GETLABEL2(i,j, outLabel) !i=unit #, j=label #<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> !dec$ attributes
dllexport :: getLabel2<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> use TrnsysData<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> use TrnsysConstants<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> integer ::
i,j,k,m,n<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> character (len=*)
:: outLabel<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> m=0<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> do k=1,N_LABELS<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'>
if(LABEL_UNIT(k).eq.i) then<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> m=m+1<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'>
if(m.eq.j) then<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> do
n=1,maxLabelLength<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'>
outLabel(n:n)=LABEL(n,k)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> enddo<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> endif<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> endif<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'> enddo<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Courier><span lang=EN-GB
style='font-size:10.0pt;font-family:Courier;color:navy'>end SUBROUTINE
GETLABEL2<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>2. Use it in C++<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'> a) add to
Trnsys.H:<br>
<font color=green><span style='color:green'>extern "C"
__declspec(dllimport) void _cdecl GETLABEL2(int* unit, int* label, <o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=green
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:green'>char* outLabel, int* lOutLabel);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 color=green
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:green'><br>
</span></font><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> b) in the code of the
type:<br>
<font color=green><span style='color:green'> <o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>char</span></font> theLabel[2000];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>int</span></font> sizeLabel;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>int</span></font> nLabel =1;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> GETLABEL2(&iunit,
&nLabel, theLabel, &sizeLabel);</span></font><font size=2 color=navy
face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>This will yield the name
of the 1<sup>st</sup> (nLabel) special card padded with spaces (you have to
scratch it out of “theLabel” by removing all trailing spaces.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>If you do not want to
modify trndll, you can use the method using External files described in my
earlier post. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Werner<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span lang=EN-GB
style='font-size:10.0pt;font-family:Tahoma;font-weight:bold'>De :</span></font></b><font
size=2 face=Tahoma><span lang=EN-GB style='font-size:10.0pt;font-family:Tahoma'>
rgaray</span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>@labein.es [mailto:rgaray@labein.es] <br>
<b><span style='font-weight:bold'>Envoyé :</span></b> lundi <st1:date
Year="2009" Day="3" Month="8" ls="trans" w:st="on">3 août 2009</st1:date> 15:01<br>
<b><span style='font-weight:bold'>À :</span></b> keilholz, werner<br>
<b><span style='font-weight:bold'>Objet :</span></b> RE: [TRNSYS-users]
Error in cpp programming</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
</span></font><font size=2 face=sans-serif><span style='font-size:10.0pt;
font-family:sans-serif'>Dear Keilholtz,</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>Thank
you for your help.</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>We´re
now trying to read the file in the "special card" way, but we´re
heving some trouble, but i think this is the correct way.</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>Could
I ask for just some more help?</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>I
attach a proforma file.</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>Would
you please tell me in which way should I call the GetLabel() function?</span></font>
<br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>In
cpp I´ve tried with the following:</span></font> <br>
<br>
<font size=2 color=blue face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'>const</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>char</span></font> *cadena=<font
color=maroon><span style='color:maroon'>""</span></font>;</span></font>
<br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>cadena
= getLabel(info[0],1);</span></font> <br>
<br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>But
it doesn´t work.</span></font> <br>
<br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>Thank
you.</span></font> <o:p></o:p></p>
</div>
</body>
</html>