Вы можете (начиная с Modelica Language 3.2 - это было недопустимо в 3.1) просто изменить значение константы следующим образом:
package Demo_v8
package Medium2
replaceable constant String name="Two components" "Medium name";
constant Integer nc=2 "Number of substances";
replaceable type Concentration = Real[nc] "Substance conc";
constant Real[nc] mw={10,20} "Substance weight";
constant Integer A=1 "Substance index";
constant Integer B=2 "Substance index";
end Medium2;
package Medium3
import M2 = Demo_v8.Medium2;
extends M2(
name="Three components" "Medium name",
nc=3 "Number of substances",
mw=cat(1, M2.mw, {30}),
redeclare type Concentration = Real[nc] "Substance conc");
constant Integer C=3 "Substance index";
end Medium3;
connector LiquidCon
replaceable package medium = Demo_v8.Medium3;
medium.Concentration c "Substance conc";
flow Real F(unit="m3/s") "Flow rate";
end LiquidCon;
end Demo_v8;
Однако я не проверял, что JModelica.org или OpenModelica могут обрабатывать она.
Кстати: сообщение об ошибке верное, поскольку повторное указание константы было недопустимым с момента появления Modelica 1.2.
http://locutus.io/php/strings/addslashes/
function addslashes( str ) {
return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
Вариация функции, предоставленной Paolo Bergantino, которая работает непосредственно на String:
String.prototype.addSlashes = function()
{
//no need to do (str+'') anymore because 'this' can only be a string
return this.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
Добавив приведенный выше код в свою библиотеку, вы сможете сделать:
var test = "hello single ' double \" and slash \\ yippie";
alert(test.addSlashes());
EDIT:
Следуя предложениям в комментариях, тот, кто обеспокоен конфликтами между библиотеками JavaScript, может добавить следующий код:
if(!String.prototype.addSlashes)
{
String.prototype.addSlashes = function()...
}
else
alert("Warning: String.addSlashes has already been declared elsewhere.");