Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language PureBasic

(GUI version)

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:1
Info:http://www.purebasic.com
Score: (3.01 in 72 votes)
; Purebasic version of 99 bottles of beer
; GUI version
; See www.purebasic.com

#WindowID=0
#GadgetID=0

Procedure CreateWindow()
  If OpenWindow(#WindowID, 0, 0, 300, 300,
#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_SizeGadget,
"99 Bottles Of Beer")
    If CreateGadgetList(WindowID())
      ListViewGadget(#GadgetId, 0, 0,
WindowWidth(),WindowHeight(), 0)
    EndIf
  EndIf
EndProcedure

Procedure.s bottle(n)
  If n = 0
      Ret.s =  "No more bottles"
  ElseIf n = 1
      Ret.s = "1 bottle"
  Else
      Ret.s = Str(n) + " bottles of beer"
  EndIf
  
  ProcedureReturn Ret
EndProcedure

CreateWindow()
For i = 99 To 1 Step -1
  AddGadgetItem(0, -1, bottle(i) + " on the wall, " +
bottle(i) + ",")
  AddGadgetItem(0, -1, "take one down, pass it around,
")
  AddGadgetItem(0, -1, bottle(i-1) + " on the wall.")
Next i

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Musical VersionGary Willoughby (Kale)11/02/060
standard versionPhilipp Winterberg04/20/050

Comments

>>  Hroudtwolf said on 01/18/06 20:22:08

Hroudtwolf Nice one.
But it should be written as console-application to be the same one like the other language-examples.

; Hroudtwolf
; 2005 PureBasic-Lounge.de

OpenConsole ()
For b=99 To 1 Step -1
PrintN (Str(b)+ " bottle(s) of beer on the wall,";)
Print (Str(b)+ " bottle(s) of beer.";)
PrintN ("Take one down, pass it around,";)
PrintN (Str(b-1)+ " bottle(s) of beer on the wall.";)
Next b
Input()
CloseConsole ()

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!

Name:

eMail:

URL:

Security Code:
  
Comment: