News:

  • August 29, 2026, 03:26:26 PM

Login with username, password and session length

Author Topic: For Next in decrementing loops  (Read 11364 times)

skills_ark

  • Jr. Member
  • **
  • Posts: 14
For Next in decrementing loops
« 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

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: For Next in decrementing loops
« Reply #1 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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: For Next in decrementing loops
« Reply #2 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  ::).

skills_ark

  • Jr. Member
  • **
  • Posts: 14
Re: For Next in decrementing loops
« Reply #3 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.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: For Next in decrementing loops
« Reply #4 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!!