Language Openedge (Progress 4GL)
Date: | 01/14/08 |
Author: | Elwin van der Meer |
URL: | http://www.star-lite.nl |
Comments: | 1 |
Info: | http://www.progress.com/ |
Score: | ![]() |
/*------------------------------------------------------------------------ File : 99bottles.p Purpose : http://www.99-bottles-of-beer.net/ Description : 99 bottles of beer Author(s) : Elwin van der Meer : elwin@star-lite.nl : http://www.star-lite.nl Created : Fri Jan 11 13:31:49 CET 2008 ----------------------------------------------------------------------*/ DEFINE VARIABLE amountofbottles AS INTEGER NO-UNDO INITIAL 99. &GLOBAL-DEFINE bbm bottles of beer &GLOBAL-DEFINE bbs bottle of beer &GLOBAL-DEFINE otw on the wall &GLOBAL-DEFINE tow Take one down and pass it around, &GLOBAL-DEFINE gts Go to the store and buy some more, FUNCTION drinkBottle RETURNS INTEGER PRIVATE (INPUT bc AS INTEGER) FORWARD. OUTPUT TO OUTPUT.txt. drinkBottle(amountofbottles). OUTPUT CLOSE. FUNCTION drinkBottle RETURNS INTEGER. IF bc >= 0 THEN DO: CASE bc: WHEN 2 THEN PUT UNFORMATTED bc " {&bbm} {&otw}, " bc " {&bbm}" SKIP "{&tow} " bc - 1 " {&bbs} {&otw}" SKIP. WHEN 1 THEN PUT UNFORMATTED bc " {&bbs} {&otw}, " bc " {&bbs}" SKIP "{&tow} no more {&bbm} {&otw}" SKIP. WHEN 0 THEN PUT UNFORMATTED "no more" " {&bbm} {&otw}, no more {&bbm}" SKIP "{>s} " amountofbottles " {&bbm} {&otw}" SKIP. OTHERWISE PUT UNFORMATTED bc " {&bbm} {&otw}, " bc " {&bbm}" SKIP "{&tow} " bc - 1 " {&bbm} {&otw}" SKIP. END CASE. drinkBottle(bc - 1). RETURN bc. END. RETURN 0. END FUNCTION.
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
Though I'd prefer to call the function 99 times in stead of once since that defeats the purpose of using a function in my opinion.
ABL ftw!