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 UniBasic

(IBM UniVerse Basic)

Date:09/23/05
Author:Stu Boydell
URL:n/a
Comments:2
Info:http://www.ibm.com/software/data/u2/universe
Score: (2.97 in 31 votes)
program MORE.BEER

*// This one is only slightly different but I hope,
*// more interesting than the previous submission.
*// Stu Boydell 2005-09-23

equ MAX.BEERS   to 99
equ CONV        to 'MR%':len(MAX.BEERS) ;* zero filled - others might be: NR (roman numerals), MP
(packed decimal), MX (hex), MO (octal), MB (binary)
equ BOTTLE.TEXT to ' bottles of beer on the wall,':@am:' bottles of beer.':@am:'Take one down, pass
it around.'

enum = ''
for i = MAX.BEERS to 1 step -1
   enum<dcount(enum,@am)+1> = str(oconv(i,CONV):@am,2)
next

subj = str(BOTTLE.TEXT:@am,MAX.BEERS-1)
subj := change(BOTTLE.TEXT,'s ',' ',2)

crt convert(@am,char(10),cats(enum,subj))

Download Source | Write Comment

Alternative Versions

Comments

>>  FRED SMITH said on 07/07/08 22:44:05

FRED SMITH Good one for the Multi-Value programmers :)

>>  Rob Thompson said on 04/11/10 02:23:14

Rob Thompson Good example, nice use of constants

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: