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

How to count? ( i++ )

How to count? ( i++ )

Hello,

I am trying to keep tab of the number of times that a curve passes a certain line but I can't get the counter to work (i++ style).

e.g.:
algorithm
  if  y==constant  then
        i:=i+1
  end if;

This only makes i:=i+1 at the moment when condition is true.. afterwards it reverts to its old value.  How do I change it for good?

Help is much appreciated.

Edited by: cporowski - Apr-27-12 12:31:03

Re: How to count? ( i++ )

Code:

when cond then

  i = pre(i)+1;
end when;

Re: How to count? ( i++ )

Thank you!

There are 0 guests and 0 other users also viewing this topic
You are here: