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 quantum

Date:10/09/06
Author:Duane Hartse
URL:n/a
Comments:0
Info:http://www.spss.com/quantum/
Score: (2.93 in 14 votes)
C quantum is a language for tabulating survey data
C
C The edit section is normally used for simple data manipulation, validation,
C and cleaning, but here I use it to write the lyrics to "99 Bottles" to a
C file named 'lyrics'.  The more typical data tabulating statements of the
C language are of no use to us here, so this really doesn't reflect what most
C of a quantum tab file actually looks like in practice.  It's not pretty,
C but it works.
C
C I needed a dummy data file to "tabulate" to get this to work, and I found
C that a text file with a single character was sufficient.  So I invoked the
C code using this command line on Unix ('99bottles' is the name of this file):
C
C echo 0 > data; quantum 99bottles data

ed

filedef lyrics report
int i 1
int b 1

C for b=99 to 0 step -1
do 10 i=0,99
    set b=99-i

C   first line
    if (b.gt.1) report lyrics b, $ bottles$
    if (b.eq.1) report lyrics $1 bottle$
    if (b.eq.0) report lyrics $No more bottles$
    report lyrics $ of beer on the wall, $
    if (b.gt.1) report lyrics b, $ bottles$
    if (b.eq.1) report lyrics $1 bottle$
    if (b.eq.0) report lyrics $no more bottles$
    reportn lyrics $ of beer.$

C   second line
    if (b.ne.0)
+       report lyrics $Take one down and pass it around, $;  set b=b-1
+   else
+       report lyrics $Go to the store and buy some more, $; set b=99
    if (b.gt.1) report lyrics b, $ bottles$
    if (b.eq.1) report lyrics $1 bottle$
    if (b.eq.0) report lyrics $no more bottles$
    reportn lyrics $ of beer on the wall.$

C   if another verse, print a blank line
    if (b.ne.99) report lyrics $\n$

10 continue

stop

end

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: