From QB64 Wiki
Revision as of 19:02, 21 August 2012 by imported>Clippy
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The STEP keyword is used in FOR...NEXT loops to skip through the count or to count down instead of up. Used in graphics to designate a relative coordinate position of a graphics object function.


FOR counter_variable = start_point TO stop_point [STEP interval]
CIRCLE STEP(0, 0), 10, 12

  • The FOR counter variable is used to designate and pass the current FOR incremented value.
  • FOR loops without the optional STEP value increment by + 1 every loop.
  • The STEP increment value can be any literal or variable numerical type. It cannot be changed inside of the loop!
  • Start and stop point values can be any literal or variable type and they cannot be changed inside of the loop.
  • STEP interval designates the portion to add or subtract from the FOR variable value.
  • When the STEP interval is positive, the start value should be less than the stop value ot the loop will be ignored.
  • When the STEP interval is negative, the start value should be greater than the stop value or the loop will be ignored.
  • In graphics statements, STEP can be used before a pair of coordinate brackets to indicate that the coordinates are relative to the last graphics statement position. IE the position will be that number of pixels away from the last graphical object.

Example: Stepping down 2 in a FOR counter loop.

FOR...NEXT i = 10 TO 0 STEP -2 PRINT i; NEXT

10 8 6 4 2 0

Note: The value of i = -2 after the loop is done.

Graphics Syntax: LINE STEP(column1%, row1%)-(column2%, row2%), color_attribute%

  • STEP coordinate positions are relative positive or negative pixel moves from the previous graphics object's last coordinate. After a CIRCLE statement, the relative coordinates would be from its center.
  • STEP can be used before the LINE, CIRCLE, PSET, PRESET, PAINT or DRAW graphics object coordinates.

Graphics Example: Using STEP coordinates to PAINT a circle's interior.

SCREEN 12 CIRCLE (100, 100), 50, 12 PAINT STEP(0, 0), 13, 12

Explanation: PAINT uses the CIRCLE's center coordinate position to paint the interior.

See also:

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page