GLOBAL beer_bottles TYPE NUMBER
GLOBAL stock$, what$, where$, action TYPE STRING
SUB init_vars()
beer_bottles = 100
stock$ = "bottles"
what$ = "of beer"
where$ = "on the wall"
action$ = "Take one down and pass it around, "
END SUB
SUB check_beers()
SELECT beer_bottles
CASE 0
stock$ = "No more bottles"
action$ = "Go to the store and buy some more, "
stock_depleted$ = CONCAT$(STR$(beer_bottles + 99)," ","bottles")
CASE 1
stock$ = CONCAT$(STR$(beer_bottles)," ","bottle")
stock_depleted$ = "no more bottles"
CASE 2
stock$ = CONCAT$(STR$(beer_bottles)," ","bottles")
stock_depleted$ = CONCAT$(STR$(beer_bottles - 1)," ","bottle")
DEFAULT
stock$ = CONCAT$(STR$(beer_bottles)," ","bottles")
stock_depleted$ = CONCAT$(STR$(beer_bottles - 1)," ","bottles")
END SELECT
END SUB
SUB report_beers()
PRINT
PRINT stock$," ", what$," ", where$, ", ", LCASE$(stock$), " ", what$, "."
PRINT action$, stock_depleted$, " ", what$," ", where$,"."
PRINT
END SUB
init_vars
REPEAT
beer_bottles = beer_bottles - 1
check_beers
report_beers
UNTIL beer_bottles EQ 0
END