Language Small Basic
(Microsoft language)
Date: | 01/31/09 |
Author: | David J Dunmore |
URL: | n/a |
Comments: | 2 |
Info: | http://msdn.microsoft.com/en-us/devlabs/cc950524.aspx |
Score: | (2.50 in 6 votes) |
'Define Variables - this appears to bey very loosely typed? bottles = 99 next_bottles = 0 bottle_text = " bottle" bottles_text = " bottles" text1 = " of beer" text2 = " on the wall" text3 = "Take one down, pass it around" text4 = "No more" text5 = "Go to the store and buy some more, 99 " text_line = " " full_stop = ". " comma = ", " 'Loop - 1 iteration per count until we've done all. For bottles = 99 To 1 Step -1 next_bottles = bottles - 1 If bottles = 2 Then TextWindow.WriteLine(bottles + bottle_text + text1 + text2 + comma + bottles + bottles_text + text1 + full_stop) TextWindow.WriteLine(text3+ " " + next_bottles + bottle_text + text1 + text2 + full_stop) Else If bottles = 1 Then ' TextWindow.WriteLine(bottles) TextWindow.WriteLine(bottles + bottle_text + text1 + text2 + comma + bottles + text1 + full_stop) TextWindow.WriteLine(text3 + comma + text4 + bottles_text + text1 + text2 + full_stop) TextWindow.WriteLine(text4 + bottles_text + text1 + text2 + comma + text4 + bottles_text + text1 + full_stop) TextWindow.WriteLine(text5 + bottles_text + text1 + text2 + full_stop) Else 'TextWindow.WriteLine(bottles) TextWindow.WriteLine(bottles + bottles_text + text1 + text2 + comma + bottles + bottles_text + text1 + full_stop) TextWindow.WriteLine(text3 + " " + next_bottles + bottles_text + text1 + text2 + full_stop) EndIf EndIf EndFor
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Alan Vickery said on 02/15/09 13:39:42
I cut and pasted the code into the Small Basic 0.3 editor and it would not run. Apparently it did not like the spaces between the concatenation operators. After I fixed that problem it ran perfect with the exception of "2 bottle of beer on the wall" should have used the bottles_text instead of bottle_text. But after 97 bottles of beer a grammatical flexibility should be expected. Good Job!
Alan Vickery said on 02/15/09 14:21:36
Nevermind it wasn't spacing it was the line wrap for the statement lines. Whoops.