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 PL/I

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:1
Info:n/a
Score: (1.67 in 9 votes)
/* And here is the PL/I version: */

 BOTTLES: PROC OPTIONS(MAIN);

   DCL NUM_BOT FIXED DEC(3);
   DCL PHRASE1 CHAR(100) VAR;
   DCL PHRASE2 CHAR(100) VAR;
   DCL PHRASE3 CHAR(100) VAR;

   DO NUM_BOT = 100 TO 1 BY -1;

      PHRASE1 = NUM_BOT||' Bottles of Beer on the wall,';
      PHRASE2 = NUM_BOT||' Bottles of Beer';
      PHRASE3 = 'Take one down and pass it around';
      DISPLAY(PHRASE1||PHRASE2);
      DISPLAY(PHRASE3);
   END;
   PHRASE1 = 'No more Bottles of Beer on the wall, ';
   PHRASE2 = 'No more Bottles of Beer';
   PHRASE3 = 'Go to the store and buy some more';
   DISPLAY(PHRASE1||PHRASE2);
   DISPLAY(PHRASE3);
 END BOTTLES;

Download Source | Write Comment

Alternative Versions

Comments

>>  Dave said on 07/07/05 20:38:46

Dave It's been a while since I coded PL/I but I think this will work. I'm fairly sure the display of the DEC will work fine. Anyway this is what I sent to my son whom I thought had created it...

I can't seem to line it up here but you'll get the idea.

DaveK

"
See improved code... based on years of coding where you didn't move stuff unless you HAD to. This would run 100% faster on the old machines. With today’s optimizers, the code would probably fix itself.

This was back in the days when you used 2 bytes to store the year and bits to keep track of things."



BOTTLES: PROC OPTIONS(MAIN);

DCL NUM_BOT FIXED DEC(3);
DCL PHRASE1 CHAR(29);
DCL PHRASE2 CHAR(16);
DCL PHRASE3 CHAR(40) VAR;

PHRASE1 = ' Bottles of Beer on the wall,';
PHRASE2 = ' Bottles of Beer';
PHRASE3 = 'Take one down and pass it around';

DO NUM_BOT = 100 TO 1 BY -1;
DISPLAY (NUM_BOT||PHRASE1||NUM_BOT||PHRASE2);
DISPLAY(PHRASE3);
END;

PHRASE3 = 'No more '
DISPLAY(PHRASE3||PHRASE1||PHRASE3||PHRASE2);
PHRASE3 = 'Go to the store and buy some more';
DISPLAY(PHRASE3);

END BOTTLES;





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: