#!sable "Derived from Smalltalk, SABLE is better viewed in an IDE than in linear files. See a syntax-colorized version at http://sable-language.com/intro/ex-beersong.aspx"! !SABLE assembly ! beersong.exe {~ console entryClass: #BottlesOfBeer.SONG method: #main:; reference: 'mscorlib.dll'; use: #System} ! ! "##############################################################################" "## SONG ##" "##############################################################################"! !SABLE namespace: #BottlesOfBeer; classes ! SONG {~ object static} "Simple class which prints the bottles-of-beer song. This is not o-o, but it shows some nice features of the SABLE language." ! ! "=============================================================================="! !SONG staticMethods in: 'entrypoint' ! main: args {ARRAY[STRING]}. "Sing the bottles song using the command line argument as the initial number, or 99 if none is provided." "Obtain the number of bottles from the first argument, or default to 99." |bottleCount| := 99. args notEmpty then: [[bottleCount := INT32 parse: args first] try catch: [:exc {DIVIDE_BY_ZERO_EXCEPTION} | "Never hits; just showing syntax"]; catch: [:exc | bottleCount := 0]]. "Print an error, or sing the song." bottleCount <= 0 then: [CONSOLE writeLine: 'Argument must be a positive integer'] else: [THIS_CLASS sing: bottleCount]. ! ! "=============================================================================="! !SONG staticMethods in: 'singing' ! sing: bottles {INT32}. {~ cilName: 'Sing'}