Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Scripting problem: for loop

Scripting problem: for loop

Hi,

The following example from Section 1.2.9 of the user guide doesn't work as expected for me:

i:="";
lst := {"Here ", "are ","some ","strings."};
s := "";
for i in lst loop
   s := s + i;
end for;

At the end of this sequence, 's' is expected to contain the concatenation of all the strings, but for me it is still empty. Is this a bug or am I doing something wrong?

OM versions tried:
"OpenModelica Compiler 1.9.1+dev (r19572) (RML version)"
"OpenModelica Compiler 1.9.0 (r17628)"

Re: Scripting problem: for loop

The problem seems to be specific to string concatenation: if I change the loop body to "s := i", s contains the last list element ("strings.") at the end of the loop.

Re: Scripting problem: for loop

Thank you, I've created a bug ticket here. You can add yourself as Cc on the ticket if you wish to be notified when it's fixed. I'll take a look at it when I have some time, it's probably not hard to fix. Not sure if I will have time this week though.

Re: Scripting problem: for loop

Thanks.

Re: Scripting problem: for loop

Sorry for taking so long, but the issue has now been fixed in revision 20241.

Re: Scripting problem: for loop

No problem. Thanks a lot.

There are 0 guests and 0 other users also viewing this topic