News:

  • May 05, 2026, 02:45:47 PM

Login with username, password and session length

Author Topic: FOR / Next and negatives  (Read 14850 times)

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
FOR / Next and negatives
« on: June 12, 2013, 10:03:33 AM »
From the help file: By Step - will increment or decrement the counter by the value that is specified. Specify a positive By Step value if the For/Next loop is counting up, or a negative By Step value if the For/Next loop is counting down. This value can be any positive or negative integer constant except 0, or any readable numeric location.

The FOR will not accept a negative constant in the By Step, so I loaded a negative number into a N and put the N in the By Step, but it won't work. ???
Circumstances don't determine who we are, they only reveal it.

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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: FOR / Next and negatives
« Reply #1 on: June 12, 2013, 10:18:34 AM »
I'd say the help is wrong.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: FOR / Next and negatives
« Reply #2 on: June 12, 2013, 10:28:02 AM »
It's hard to get good help these days.
An output is a PLC's way of getting its inputs to change.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: FOR / Next and negatives
« Reply #3 on: June 12, 2013, 10:32:24 AM »
I'd say I said something like "it works like BASIC's FOR/NEXT loop" which does support counting down...so...the help problem is likely the engineer that lied...
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: FOR / Next and negatives
« Reply #4 on: June 12, 2013, 12:45:27 PM »
Okay. I can work around it.
Circumstances don't determine who we are, they only reveal it.

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

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: FOR / Next and negatives
« Reply #5 on: June 12, 2013, 12:58:16 PM »
Just stop being so negative and you'll be fine!   ;D
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: FOR / Next and negatives
« Reply #6 on: June 12, 2013, 02:19:59 PM »
Okay. I can work around it.

You should be used to that by now.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: FOR / Next and negatives
« Reply #7 on: June 12, 2013, 03:30:05 PM »
Okay. I can work around it.

You should be used to that by now.

Hey, I'm totally impressed to be using a FOR/NEXT in a PLC... negatives or not! ;D
Circumstances don't determine who we are, they only reveal it.

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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: FOR / Next and negatives
« Reply #8 on: June 12, 2013, 03:39:31 PM »
I think we talked about doing up and down at the time we designed it, and convinced ourselves that since we support variables for every parameter in the FOR, there were 100 ways it could go horribly wrong. In an effort to reduce that to 80 or 90, we decided to count up only. ::)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO