Modelica에서 문자열을 실행하려고합니다. 이 문자열은 필요할 때 변경할 수 있도록 변수에 저장됩니다.어떻게 문자열을 실행 가능하게 만들 수 있습니까?
function Test
input String inComp="resistor.R:=2";
output String outComp;
algorithm
outComp:=inComp;
end Test;
당신은 내가 Dymola를 사용하고
을 기쁘게 수 없습니다.
내가해야 할 일은 다음과 같습니다.
- 텍스트 파일의 구성 요소 이름을 읽거나 기능을 실행하는 동안 입력하십시오. -이 구성 요소의 매개 변수를 변경하십시오. 이 코드는 다음과 같습니다.
function Test
input String inComp="resistor"; //Entered by the user, or read from a text file
output Real result;
algorithm
inComp.R :=2 ; /*This is incorrect since it wouldn't understand that
I want to enter : resistor.R := 2; */
result := inComp.R ; //In order to view the result
end Test;
Modelica에는 다른 여러 언어에서 지원되는 eval() 기능과 동일한 기능이 있습니까? 그렇다면 그것을 사용할 수 있습니다. 그러나 피할 수 있으면하지 마십시오. – GordonM