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 Rel

Date:05/05/06
Author:Dave Voorhis
URL:n/a
Comments:0
Info:http://dbappbuilder.sourceforge.net/Rel.html
Score: (4.33 in 3 votes)
/* 99 Bottles of Beer in Rel.  

   Rel implements an extended subset of Date and Darwen's "Tutorial D" 
   true relational database language.

   This example (unecessarily and inefficiently) creates a relation variable
   to hold the bottles, which provides an opportunity to demonstrate 
   some of the built-in relational operators. 

   See http://dbappbuilder.sourceforge.net

   Copyright (c) 2006 Dave Voorhis
*/

VAR bottles LOCAL RELATION {
   bottlecount INTEGER, 
   description CHAR
} KEY {bottlecount};

VAR i INTEGER;
DO i := 1 TO 99
   VAR descript CHAR;
   IF i > 1 THEN
      descript := "bottles of beer on the wall, " || i || 
                          " bottles of beer.  Take one down, pass it around,";
   ELSE
      descript := "bottle of beer on the wall, " || i || 
                          " bottle of beer.  Take it down, pass it around," || 
                          " no more bottles of beer on the wall.";
   END;
   bottles += TUPLE {bottlecount i, description descript};
END;

FOR bottles ORDER DESC bottlecount BEGIN
   WRITELN bottlecount || " " || description;
END;

Download Source | Write Comment

Alternative Versions

Comments

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: