Author Message

Hi John,

Thanks for raising the question... it seems unusual until the reason
is explained.  The counter increment value must be of the same data
type as the loop counter... -1 is not a valid WORD value, so it is not
a valid increment value for a FOR loop that uses a WORD variable as
the counter.  

BTW, this rule applies to all powerbasic compilers, not just PB/DOS.

Theoretically the compiler could do automatic type conversions so you
could use any increment data type, but that would negatively impact on

In any case, using integer variables for loop counters is most
efficient in PB/DOS (although WORD types are not far behind) , so
using a -1% increment value is perfectly acceptable.

I hope this helps!


>In PB 3.5, if variable X is a word (unsigned 16 bits) variable, it
>looks like the loop

>    FOR X = 15 TO 0 STEP -1

>       (do some stuff)

>    NEXT

>never executes. Not a big deal, just interesting.

>I was just hacking a CRC-16 thingie, and this zapped me until I
>changed the index variable to X%. I like word variables, but they have
>some personality.


PowerBASIC Support

PowerBASIC, Inc.      | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.*-*-*.com/

Thu, 21 Apr 2005 13:39:15 GMT  
 [ 1 post ] 

 Relevant Pages 

1. An interesting link maybe for people interested in how one could use Rexx in HTML ...

2. Interesting Statistics

3. Interesting inner products

4. interested in proposals for Object Orientation

5. Income Opportunities from Investment Banker - Interested?

6. Directory of interested APL users

7. Interesting feature of J


9. interesting quote

10. You interested?ZFLCRZDDT

11. You interested?

12. You Interested? 50%


Powered by phpBB® Forum Software