_TITLE "Choose from multiple items with 2 lines of code" ' b+ 2020-09-02
IF weather
= 1 THEN w$
= "Hot" IF weather
= 2 THEN w$
= "Sunny" IF weather
= 3 THEN w$
= "Cloudy" IF weather
= 4 THEN w$
= "Windy" IF weather
= 5 THEN w$
= "Rainy" IF weather
= 6 THEN w$
= "Cold" IF weather
= 7 THEN w$
= "Snowy" IF weather
= 8 THEN w$
= "Hail"
' Get random choice of multiple items in 2 lines of code!
'Setup: 11 items seperate them by equal amount, this is one more than longest 6 chars so can read items
' 12345671234567123456712345671234567123456712345671234567123456712345671234567
weather$ = "Hot Sunny Cloudy Windy Rainy Stormy Cold Snowy Hail Sleet Foggy"
FOR i
= 1 TO 20 ' demo random choice
' In the Run, call for an random item MID$ gets the section in the string, _TRIM$ removes spaces
' length * items length
PRINT "Weather forecast: "; w$