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 AmigaE

(exception handler, EXIT cond)

Date:11/13/05
Author:Harry Sintonen
URL:http://www.iki.fi/sintonen/
Comments:3
Info:http://en.wikipedia.org/wiki/AmigaE_programming_language
Score: (3.00 in 38 votes)
-> AmigaE version of 99 Bottles of Beer
->
-> About AmigaE: http://en.wikipedia.org/wiki/AmigaE_programming_language
->
-> Written by Harry Sintonen <sintonen@iki.fi>.

RAISE "MEM" IF String() = NIL

PROC main() HANDLE
  DEF p:PTR TO CHAR
  DEF i

  FOR i := 99 TO 0 STEP -1
    p := gen(i)
    PrintF('\s on the wall, \s.\n', p, p)
    Dispose(p)

    EXIT i = 0

    p := gen(i - 1)
    PrintF('Take one down pass it around, \s on the wall.\n', p)
    Dispose(p)
  ENDFOR

  PrintF('Go to the store and buy some more, 99 bottles of beer on the wall.\n')

EXCEPT

  PrintF('Oops. An exception caught!\n')

ENDPROC

PROC gen(i)
  DEF s

  s := String(24)

  IF i > 1
    StringF(s, '\d bottles', i)
  ELSE
    StrCopy(s, IF i = 0 THEN 'no more bottles' ELSE '1 bottle')
  ENDIF

  StrAdd(s, ' of beer')
ENDPROC s

Download Source | Write Comment

Alternative Versions

Comments

>>  Samurai_Crow said on 04/15/06 05:20:50

Samurai_Crow I thought AmigaE used Writeln instead of PrintF most of the time. It simplifies all of the complexities of the C-like syntax.

>>  >>=I)@®kLøR(I=<< said on 09/06/06 15:38:36

>>=I)@®kLøR(I=<< gd

>>  tryo said on 06/19/07 22:25:29

tryo It should use DisposeLink() instead of Dispose(), else it would never free the strings.

@Samurai_Crow

Writeln sounds quite much like ARexx. In E you usually use WriteF()

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: