Skip to content
Andrew Owen edited this page May 30, 2023 · 2 revisions

FOR


FOR loop_var = start TO stop [STEP step]

Initiates a FOR to NEXT loop.

Initially, loop_var is set to start. Then, the statements between the FOR statement and the NEXT statement are executed and loop_var is incremented by step (if step is not specified, by 1). This is repeated until loop_var has become greater than stop. Execution then continues at the statement following NEXT. The value of loop_var equals stop+step after the loop.

Parameters

  • loop_var is a numeric variable.
  • start, stop and step are numeric expressions.

Errors

  • No NEXT statement is found to match the FOR statement: FOR without NEXT occurs at the FOR statement.
  • loop_var is a string variable or start, stop, or end has a string value: Type mismatch.
  • loop_var is an array element: Syntax error.
  • loop_var is an integer variable and a start, stop or step is outside the range [-32768, 32767]: Overflow.

Welcome to the SE BASIC wiki


  • Press RETURN to return to this menu.
  • Enter the name of a TOPIC to display it.
  • Enter EXIT to return to BASIC.

Choose from the following topics:

  1. Quick start guide: QUICK
  2. User's guide: USER
  3. Configuration guide: CONFIG
  4. Language guide: LANGUAGE
  5. Language reference: BASIC
  6. Technical reference: TECH
  7. Developer's guide: DEV
  8. Acknowledgemets: CREDITS
  9. Licenses: LICENSE
Clone this wiki locally