Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: skills_ark on February 04, 2014, 11:55:44 AM

Title: For Next in decrementing loops
Post by: skills_ark on February 04, 2014, 11:55:44 AM
The step index doesn't accept -1 steps and the instruction directions lead me to expect it was supposed to. Am I missing something? Thanks
Title: Re: For Next in decrementing loops
Post by: plcnut on February 04, 2014, 12:35:14 PM
Help file is wrong.

You have to use a normal loop and then MATH or DEC inside the loop to calculate the decrement.
Title: Re: For Next in decrementing loops
Post by: franji1 on February 04, 2014, 12:44:51 PM
Sorry, no.  Due to the flexibility of having a variable step and the desire to have the loop's index maintain the "last" value upon exiting the FOR/NEXT loop, the implementation became greatly simplified (read "fast") by keeping the step "postive" only.

Use a MATH box to calculate a "downto" FOR/NEXT index from the actual FOR/NEXT index.  Sorry about that  ::).
Title: Re: For Next in decrementing loops
Post by: skills_ark on February 04, 2014, 12:59:30 PM
Thought that might be the case so I had done what you suggested. This plc is the coolest thing I have used in a while. Thanks for the hard work.
Title: Re: For Next in decrementing loops
Post by: franji1 on February 04, 2014, 01:21:28 PM
Thought that might be the case so I had done what you suggested.
  Again, sorry.  We wanted to have it support negative steps, but the behavior became way way too complex.
Quote
This plc is the coolest thing I have used in a while. Thanks for the hard work.
Thanks!  Thank YOU for using it!!