Hi Paul,
in the meantime i have investigated this further by looking in the generated code as you suggest:
the root-cause, i think is burried in the EwLoadString method. I think, that this method simply returns the location of the constant given as its argument. So the string variable points to the ram-address where the constant is located. Some dumb string-modification on our side writes to this variable, thus changing the constant string.
here is the chora-code that makes the problem:
$rect <1990,410,2240,450>
method string ReadLanguageRaw()
{
var string langC = "DE";
$if !$prototyper
native (langC){
langC[0] = eeprom.language[0];
langC[1] = eeprom.language[1];
langC[2] = 0;
langC[3] = 0;
}
$endif
return langC;
}
this is generated to ansiC:
/* 'C' function for method : 'Supervisor::DeviceClassLT.ReadLanguageRaw()' */
XString SupervisorDeviceClassLT_ReadLanguageRaw( SupervisorDeviceClassLT _this )
{
XString langC;
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( _this );
langC = EwLoadString( &_Const0006 );
{
langC[0] = eeprom.language[0];
langC[1] = eeprom.language[1];
langC[2] = 0;
langC[3] = 0;
}
return langC;
}
and here is the code-snipet, that is generated from the above languageObj2Str:
XString SupervisorDeviceClassLT_languageObj2Str( SupervisorDeviceClassLT _this,
XLangId lang )
{
XString langC;
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( _this );
EwTrace( "%s%l", EwLoadString( &_Const000F ), lang );
langC = 0;
if ( lang == English )
{
EwTrace( "%s", EwLoadString( &_Const0010 ));
langC = EwLoadString( &_Const0009 );
}
else
if ( lang == Russisch )
{
EwTrace( "%s", EwLoadString( &_Const0011 ));
langC = EwLoadString( &_Const000A );
}
else
if ( lang == Franzoesisch )
{
EwTrace( "%s", EwLoadString( &_Const0012 ));
langC = EwLoadString( &_Const000B );
}
else
if ( lang == Polnisch )
{
EwTrace( "%s", EwLoadString( &_Const0013 ));
langC = EwLoadString( &_Const000C );
}
else
if ( lang == Spanisch )
{
EwTrace( "%s", EwLoadString( &_Const0014 ));
langC = EwLoadString( &_Const000D );
}
else
if ( lang == Niederlaendisch )
{
EwTrace( "%s", EwLoadString( &_Const0015 ));
langC = EwLoadString( &_Const000E );
}
else
{
EwTrace( "%s", EwLoadString( &_Const0016 ));
EwTrace( "%s%s", EwLoadString( &_Const0017 ), langC );
langC = EwLoadString( &_Const0006 );
EwTrace( "%s%s", EwLoadString( &_Const0018 ), langC );
}
EwTrace( "%s%s", EwLoadString( &_Const0019 ), langC );
return langC;
}
So the _Const0006 gets modified by ReadLanguageRaw.
This is extremely hard to see in the Chora-Sourcecode. I would expect, when i assign a Constant to a Variable, that this will be copied to a new location where the variable points to...
This now has been popped up, because i have moved all the functions that interact with the middleware to one class. before they were distributed through different units and thus the constant get declared separatly in each unit, so the constant got overwritten in one unit, but it was read from another unit...
greetings Daniel Schroll