The Cycle Command

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

cycle.png

Command Summary

Prematurely ends a cycle of a loop.

Command Syntax

:Cycle

Menu Location

Starting in the program editor:

  • Press F2 to enter the Control menu.
  • Press 8 to enter the Transfers submenu.
  • Press 3 to select Cycle.

Calculator Compatibility

This command works on all calculators.

Token Size

4 bytes

The Cycle command ends the current cycle of a For..EndFor, Loop..EndLoop, or While..EndWhile loop, as though the corresponding End were there. It doesn't exit the loop forever; if the loop would have repeated, it goes back to the beginning. However, if the loop is ready to end (if the counter is equal to the end value, for a For loop, or if the condition is false, for a While loop), it exits the loop and continues after the EndFor or EndWhile command.

An example of Cycle in a For loop:

:For num,1,100
: If isPrime(num)
:  Cycle
: Disp num
:EndFor

This loop prints all the composite numbers between 1 and 100. Here's how it works: for every number, it first checks whether or not it's prime. If it is, the program goes back to the beginning of the loop with the next number. On the other hand, if the number is composite, the program continues to the Disp command, then hits EndFor and goes back to the beginning of the loop as well.

If the Cycle instruction is inside multiple loops, one nested in the other, it works with the innermost loop.

Error Conditions

560 - Invalid outside Loop..EndLoop, For..EndFor, or While..EndWhile blocks happens when Cycle is used outside a loop.

Related Commands

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.