Skip to main content

TO

Syntax

FOR iterator intial_value TO ending_value ... NEXT [ iterator ] SELECT case_comparison_value CASE lower_bound TO upper_bound ... END SELECT

Description

The TO keyword is used to define a certain numerical range. This keyword is valid only if used with FOR ... NEXT and SELECT / CASE . In the first syntax, the TO keyword defines the initial value of the iterator in a FOR statement, and the ending value. In the second syntax, the TO keyword defines lower and upper bounds for CASE comparisons.

Example

'' this program uses bound variables along with the TO keyword to create an array, store random

FOR it = minimum_temp_count TO maximum_temp_count

'' display a message based on temperature using our min/max danger zone bounds

SELECT array( it )

CASE min_low_danger TO max_low_danger

COLOR 11

PRINT "Temperature" ; it ; " is in the low danger zone at" ; array( it ) ; " degrees!"

CASE min_medium_danger TO max_medium_danger

COLOR 14

PRINT "Temperature" ; it ; " is in the medium danger zone at" ; array( it ) ; " degrees!"

CASE min_high_danger TO max_high_danger

COLOR 12

PRINT "Temperature" ; it ; " is in the high danger zone at" ; array( it ) ; " degrees!"

CASE ELSE

COLOR 3

PRINT "Temperature" ; it ; " is safe at" ; array( it ) ; " degrees."

END SELECT

NEXT it

SLEEP

Differences from other BASICs

  • none

See also