Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: plcnut on June 12, 2013, 10:03:33 AM

Title: FOR / Next and negatives
Post by: plcnut 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. ???
Title: Re: FOR / Next and negatives
Post by: BobO on June 12, 2013, 10:18:34 AM
I'd say the help is wrong.
Title: Re: FOR / Next and negatives
Post by: b_carlton on June 12, 2013, 10:28:02 AM
It's hard to get good help these days.
Title: Re: FOR / Next and negatives
Post by: BobO 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...
Title: Re: FOR / Next and negatives
Post by: plcnut on June 12, 2013, 12:45:27 PM
Okay. I can work around it.
Title: Re: FOR / Next and negatives
Post by: Controls Guy on June 12, 2013, 12:58:16 PM
Just stop being so negative and you'll be fine!   ;D
Title: Re: FOR / Next and negatives
Post by: BobO on June 12, 2013, 02:19:59 PM
Okay. I can work around it.

You should be used to that by now.
Title: Re: FOR / Next and negatives
Post by: plcnut 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
Title: Re: FOR / Next and negatives
Post by: BobO 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. ::)