Project

General

Profile

Bug #882

For loop fails if Step is set using hex or a binary *constant*

Added by Brian Flanagan over 2 years ago. Updated almost 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
AOZ Developers
Target version:
Start date:
12/24/2021
Due date:
% Done:

0%

Estimated time:
Affected version:

Description

I can use a variable without a problem. I can also use a decimal constant.
If, however, I use a binary or hex constant, the For loop will continue past the limit.
For example:

This works:

gbStart=$E1E1
gbEnd=$FFFF
gbStep=$202
For gb=gbStart To gbEnd Step gbStep
  Locate 0,0 : Print Hex$(gb,6);
  Print Using "-##########";gb
  Wait Key
Next gb

This will also work:

gbStart=$E1E1
gbEnd=$FFFF
gbStep=$202
For gb=gbStart To gbEnd Step 514
  Locate 0,0 : Print Hex$(gb,6);
  Print Using "-##########";gb
  Wait Key
Next gb

This will NOT work:

gbStart=$E1E1
gbEnd=$FFFF
gbStep=$202
For gb=gbStart To gbEnd Step $202
  Locate 0,0 : Print Hex$(gb,6);
  Print Using "-##########";gb
  Wait Key
Next gb

This also will NOT work:

gbStart=$E1E1
gbEnd=$FFFF
gbStep=$202
For gb=gbStart To gbEnd Step %001000000010
  Locate 0,0 : Print Hex$(gb,6);
  Print Using "-##########";gb
  Wait Key
Next gb
#1

Updated by David Baldwin over 2 years ago

Why would you do that Brian? ;)

#2

Updated by David Baldwin about 2 years ago

  • Status changed from New to Resolved
#3

Updated by Brian Flanagan about 2 years ago

  • Status changed from Resolved to Feedback
  • Affected version changed from 1.0.0 (B11) u17 to 1.0.0 (B12) u19

Still fails. (re-tested in newest 1.0.0 (B12) u19 version (as of 2/16/2022)

Loop still continues beyond the limit.
Here's another example:

gbStart=$E1E1
gbEnd=$FFFF
gbStep=$202
Print Using "Start: -##########";gbStart
Print Using "End:   -##########";gbEnd
For gb=gbStart To gbEnd Step $202
    Locate 0,3
    Print Hex$(gb,6);
    Print Using "-##########";gb;
    If gb > gbEnd Then Locate 20,1 : Print Using "< -##########";gb
    Wait 0.3
Next gb

Why? For some applications, it's easier to do things in Hex!

#4

Updated by Francois Lionet almost 2 years ago

  • Status changed from Feedback to Resolved

Seems fixed!

Also available in: Atom PDF