Language AppleSoft
Date: | 04/20/05 |
Author: | Anonymous |
URL: | n/a |
Comments: | 7 |
Info: | n/a |
Score: | (3.03 in 67 votes) |
0 REM ************************ 1 REM ** 99 BOTTLES OF BEER ** 2 REM ** APPLESOFT VERSION ** 3 REM ** BY LEE FASTENAU ** 4 REM ************************ 10 TEXT : HOME 20 FOR Z = 99 TO 1 STEP - 1 30 A = Z: GOSUB 1000 40 PRINT " ON THE WALL." 50 GOSUB 1000 60 PRINT "." 70 GOSUB 2000 80 A = Z - 1: GOSUB 1000 90 PRINT " ON THE WALL." 100 NEXT 110 END 1000 IF A < 1 THEN A$ = "NO MORE": GOTO 1020 1010 A$ = STR$ (A) 1020 A$ = A$ + " BOTTLE" 1030 IF A < > 1 THEN A$ = A$ + "S" 1040 A$ = A$ + " OF BEER" 1050 PRINT A$; 1060 RETURN 2000 A$ = "TAKE" 2010 IF A > 1 THEN A$ = A$ + " ONE": GOTO 2030 2020 A$ = A$ + " IT" 2030 A$ = A$ + " DOWN, PASS IT AROUND." 2040 PRINT A$ 2050 RETURN
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
Lee Fastenau said on 03/19/08 16:14:46
Anonymous? My name's in the comments!
barrym said on 04/05/10 03:00:15
Nicely done. I only have one suggestion:
Applesoft's PRINT statement is much more versatile than you give credit.
By combining lines 1040 and 1050 into 1040 PRINT A$;" OF BEER";
and lines 2030 and 2040 into 2040 PRINT A$;" DOWN AND PASS IT AROUND"
you have not made your program any less readable, but you have made
it shorter and faster (by less executed statements and fewer garbage
collections).
barrym said on 04/05/10 03:08:18
Uh, oh yeah. Better make that two suggestions:
You forgot to send someone to the store to buy some more!
Lee Fastenau said on 05/12/10 21:31:10
Hey barrym, true, it is less code and slightly faster, but it's BASIC. I'm pretty familiar with micro-optimizations for both size and speed: http://www.ioyu.com/io/atari/reflex/source/reflex99a.txt
barrym said on 05/16/10 04:00:44
Lee, thanks for responding. I checked out your reflex99a source and I was
immediately impressed by your 6502 skills (my favorite processor EVER).
Please forgive me if the following questions make me an annoying butthole.
Why would a person with your obvious talents go through the trouble of
submitting a clearly sub-optimal and incomplete entry when a few extra
minutes of your time would have easily nailed it? Don't students, hobbyists,
and historians who come here looking for code examples deserve correct,
efficient, complete examples? Don't you want your name on a program (even a
trivial one) that you can be proud of?
If you feel that I'm over-reacting, please accept my apology.
Lee Fastenau said on 09/23/10 00:53:04
barrym, I believe I nailed it in terms of achieving what I'd set out to do, which was to showcase some very basic features of Applesoft in a clear, readable manner. Of the great many speed optimizations that _could_ be made to this program, why you chose to harp on two rather trivial ones is a mystery to me. (p.s.: Your suggested changes could be further optimized by removing the semicolons, saving a few cycles in the lexical parser. So I guess your suggestions were both trivial _and_ sub-optimal... oh well, nobody's perfect.)
barrym said on 09/23/10 07:59:47
Looking back, I can see that I was clearly in 'annoying butthole' mode. Thanks for
setting me straight, sincerely.