Can't do for-next countdown in Blockly

westaust55

Moderator
Sorry but I do not have a firm answer since I program in the text based BASIC programming language.

The PICAXE website makes reference to FOR...NEXT loop structures but the pdf manual does not expand on loop structures though the toolbox image shows loops.

In BASIC there is an optional parameter for FOR...NEXT loops - this is the STEP parameter.
By default the step/increment is +1 but by adding the word STEP a different increment can be defined.
For example:

FOR b0 = 1 to 50 STEP 5
; do something
NEXT
And

FOR b0 = 50 to 1 STEP -5
; do something
NEXT

Hopefully the above may give you a clue to a decrementing loop in BLOCKLY.
 

coparu67

Senior Member
Blockly doesn't work with negative numbers (I think).
A short workaround is to use a second variable.

But I don't understand why there is not a countdown block. I think its implementation is not very dificult.
 

Technical

Technical Support
Staff member
We will add the suggestion of a countdown block to our list. However it is quite easy to duplicate using 'decrement' and a 'repeat until' block.
 
Top