Anonymous user
Execute HQ9+: Difference between revisions
m
→{{header|REXX}}: changed/added comments and whitespace, changed indentations, added comment in the REXX section header.
m (added whitespace before the TOC (table of contents), added whitespace around al link.) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations, added comment in the REXX section header.) |
||
Line 1,313:
=={{header|REXX}}==
Note that the actual text of the ''Hello, world!'' message can differ among definitions.
<lang rexx>/*REXX program implements the HQ9+ language. ───────────────────────────────────────*/
arg pgm . /*obtain optional argument.*/
select▼
when ?=='
when ?=='Q' then do j=1 for sourceline(); say sourceline(j); end /*j*/▼
otherwise say 'invalid HQ9+ instruction:' ?▼
when ?=='+' then accumulator=accumulator+1▼
end /*instructions*/▼
▲ otherwise say 'invalid HQ9+ instruction:' ?
exit /*stick a fork in it, we're done.*/▼
▲ end /*select*/
▲ end /*instructions*/
99: do j=99 by -1 to 1▼
▲exit /*stick a fork in it, we're all done. */
say j 'bottle's(j) "of beer the wall,"▼
/*──────────────────────────────────────────────────────────────────────────────────────*/
say j 'bottle's(j) "of beer."▼
▲99: do j=99 by -1 to 1
say 'Take one down, pass it around,'▼
▲ say j 'bottle's(j) "of beer the wall,"
▲ say 'Take one down, pass it around,'
say n 'bottle's(j-1) "of beer the wall."▼
if n==0 then n='no' /*cheating to use 0. */
say 'no more bottles of beer.'▼
say 'Go to the store and buy some more,'▼
say '
▲ say 'no more bottles of beer.'
return▼
▲ say 'Go to the store and buy some more,'
s: if arg(1)==1 then return ''; return "s" /*a simple pluralizer.*/</lang>▼
▲ return
'''output''' when using the input of: <tt> H+Q </tt>▼
/*──────────────────────────────────────────────────────────────────────────────────────*/
▲s: if arg(1)==1 then return ''; return "s" /*a simple pluralizer.*/</lang>
hello, world▼
<pre>
Hello, world!
▲ select
Hello, world!
▲ when ?=='Q' then do j=1 for sourceline(); say sourceline(j); end
▲ when ?=='+' then accumulator=accumulator+1
▲ end /*select*/
▲ if n==0 then n='no' /*cheating to use 0. */
</pre>
|