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 Conzept 16

Date:08/28/07
Author:Christian Worreschk
URL:n/a
Comments:0
Info:http://www.vectorsoft.de
Score: (4.00 in 4 votes)
// 99 bottles of beer - Conzept 16 version
// developed by Christian Worreschk 
// August 28th, 2007 - Mainz, Germany
// 
// This language is part of the development environment "Conzept 16" developped by vectorsoft
// http://www.vectorsoft.de/


DEFINE {
  BOTTLE_COUNT : 99
}

SUB BottlePluralizer( aBottleCount : int ) : alpha
  Local{ tBottleString : alpha }{  
  
  SWITCH( aBottleCount ) {
    CASE 0  : tBottleString # 'no more bottles';
    CASE 1  : tBottleString # '1 bottle';
    DEFAULT : tBottleString # cnvAI( aBottleCount ) +' bottles';
  }  
  
  RETURN tBottleString;
}

SUB buildFirstPartOfVerse( aBottleCount : int ) : alpha
  Local{ tFirstPart : alpha ; tBottleString : alpha }{
  
  tBottleString # BottlePluralizer( aBottleCount );
  tFirstPart    # tBottleString + ' of beer on the wall, ' + tBottleString + ' of beer.';  
 
  IF ( aBottleCount = 0 ) {
    tFirstPart # 'N' + StrDel( tFirstPart, 1, 1 );
  }
  
  RETURN tFirstPart;
}

SUB buildSecondPartOfVerse( aBottleCount : int ) : alpha
  Local{ tSecondPart : alpha ; tBottleString : alpha }{
 
  IF ( aBottleCount = 0 ) {    
    aBottleCount # BOTTLE_COUNT;
    tSecondPart  # 'Go to the store and buy some more, ';
  } ELSE {
    dec( aBottleCount );    
    tSecondPart # 'Take one down and pass it around, '; 
  }
  
  tBottleString # BottlePluralizer( aBottleCount );  
  tSecondPart # tSecondPart + tBottleString + ' of beer on the wall.';
  
  RETURN tSecondPart;
}

SUB SingTheSong()
  Local{ tBottleCounter : int ; tFirstPart : alpha ; tSecondPart : alpha }{
  
  FOR tBottleCounter # BOTTLE_COUNT;
  LOOP dec( tBottleCounter );
  WHILE ( tBottleCounter >= 0 ) {  
    tFirstPart  # buildFirstPartOfVerse( tBottleCounter );
    tSecondPart # buildSecondPartOfVerse( tBottleCounter );
    
    // Output in Debugger
    DbgTrace( tFirstPart );    
    DbgTrace( tSecondPart );
    DbgTrace('');   
  }
}

MAIN() {
  DbgConnect( '*', y, y );

  SingTheSong();

  DbgDisConnect();
}

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: