I am new to modelica/Dymola and i have a question about arrays.
I have seen in the Modelica language definition (V2.2) the following expression:
QUELLTEXT
Integer i;
Integer sign_of_i1=if i<0 then -1 elseif i==0 then 0 else 1;
Now I want to do something more or less similar with an array but it doesn't work. As you can see in the folowing code I want to use Parameter n to define the length of my Array and in a second step I want to fill the Array where the if-expression should take care of the length of the assigned Vector (The Values 1,2,3 and 4 are examples so lam=1:n is not a solution for me
QUELLTEXT
parameter Integer n;
parameter Real lam[n] if n==4 then [1,2,3,4] elseif n==3 then [1,2,3] elseif (n==2) then [1,2] else [1];
Unfortuantely this piece of code causes the following error message:
ZITAT
Error: declaration window line 69 column 35, syntax error at "then" missing { EndOfFile IMPORT CLASS_ MODEL RECORD BLOCK CONNECTOR EXPANDABLE TYPE PACKAGE EXTERNAL FUNCTION END EXTENDS REPLACEABLE PARTIAL ENCAPSULATED REDECLARE EQUATION FINAL PUBLIC PROTECTED ALGORITHM ANNOTATION INNER OUTER INITIAL IDENT STRING type-prefix ) ; , }
Error: declaration window line 69 column 43, syntax error at "2" missing IDENT
Error: declaration window line 69 column 45, syntax error at "3" missing IDENT
Error: local redefinition of Error
Location of previous declaration:
Error: declaration window line 69 column 47, syntax error at "4" missing IDENT
Error: local redefinition of Error
Location of previous declaration:
Error: declaration window line 69 column 70, syntax error at "2" missing IDENT
Error: local redefinition of Error
Location of previous declaration:
Error: declaration window line 69 column 72, syntax error at "3" missing IDENT
Error: local redefinition of Error
Location of previous declaration:
Error: declaration window line 69 column 87, syntax error at ")" missing ;
Error: declaration window line 69 column 94, syntax error at "[" missing { EndOfFile EXTERNAL END }
What do i do wrong? Do you have any Idea?
Thanx in advance
Hannes Wagner

