Language BLISS
(bliss style)
| Date: | 04/20/05 |
| Author: | Ron Brender |
| URL: | n/a |
| Comments: | 0 |
| Info: | n/a |
| Score: |
module NINTY_NINE_BOTTLES_CT (main=BOTTLES) =
!
! "99 Bottles of Beer on the Wall"
! using BLISS on DIGITAL's Alpha OpenVMS
! by Ron Brender, brender@zko.dec.com
!
begin
external routine
printf : novalue external_name('DECC$GXPRINTF');
!
! To "port" this program to UNIX or WNT, use
! external_name('printf') or the appropriate lower case
! compilation option instead of the above.
macro
PUT_TEXT(T) =
printf(uplit(%asciz '%s'), uplit(%asciz T))
%,
PUT_NL (dummy) =
printf(uplit(%asciz %string(%char(10))))
%;
compiletime
TEMP = 0;
! In principle, the complete text can be constructed at compile-time and
! output with a single PUT_TEXT call, however, that runs up against a
! compile-time maximum string length. This implementation constructs a
! complete stanza at compile-time.
!
macro
BOTTLE_S(COUNT) =
%if COUNT eql 1 %then 'bottle' %else 'bottles' %fi
%,
BOTTLE_COUNT(COUNT) =
%assign(TEMP, COUNT)
%if TEMP eql 0 %then 'No' %else %string(%number(TEMP)) %fi
%,
BOTTLE_STANZA(COUNT) =
PUT_TEXT(%string(
BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT),
' of beer on the wall; ',
BOTTLE_COUNT(COUNT), ' ', BOTTLE_S(COUNT), ' of beer', %char(10),
'Take one down and pass it around', %char(10),
BOTTLE_COUNT(COUNT-1), ' ', BOTTLE_S(COUNT-1),
' of beer on the wall', %char(10),
%char(10)))
%,
BOTTLE_TEXT(COUNT)[] =
BOTTLE_STANZA(COUNT);
%if COUNT gtr 1 %then
BOTTLE_TEXT(COUNT - 1)
%fi
%;
global routine BOTTLES : novalue =
begin
! Title
!
PUT_NL();
PUT_TEXT(' "99 Bottles of Beer on the Wall"'); PUT_NL();
PUT_NL();
BOTTLE_TEXT(99);
end;
end
eludom
Download Source | Write Comment
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!
Comments