Execute HQ9+: Difference between revisions
Content added Content deleted
(Execute HQ9+ en FreeBASIC) |
(Execute HQ9+ en BASIC256) |
||
Line 351: | Line 351: | ||
Return output |
Return output |
||
}</lang> |
}</lang> |
||
=={{header|BASIC256}}== |
|||
{{trans|FreeBASIC}} |
|||
<lang BASIC256> |
|||
# Intérprete de HQ9+ |
|||
global codigo |
|||
codigo = "" |
|||
function HQ9plus(codigo) |
|||
acumulador = 0 |
|||
HQ9plus1 = "" |
|||
for cont = 1 to length(codigo) |
|||
op = upper(mid(codigo, cont, 1)) |
|||
begin case |
|||
case op = "H" |
|||
HQ9plus1 = HQ9plus1 + "Hello, world!" |
|||
case op = "Q" |
|||
HQ9plus1 = HQ9plus1 + codigo |
|||
case op = "9" |
|||
for botellas = 99 to 1 step -1 |
|||
HQ9plus1 = HQ9plus1 + string(botellas) + " bottle" |
|||
if (botellas > 1) then HQ9plus1 = HQ9plus1 + "s" |
|||
HQ9plus1 = HQ9plus1 + " of beer on the wall, " + string(botellas) + " bottle" |
|||
if (botellas > 1) then HQ9plus1 = HQ9plus1 + "s" |
|||
HQ9plus1 = HQ9plus1 + " of beer," + chr(13) + chr(10) + "Take one down, pass it around, " + string(botellas - 1) + " bottle" |
|||
if (botellas > 2) then HQ9plus1 = HQ9plus1 + "s" |
|||
HQ9plus1 = HQ9plus1 + " of beer on the wall." + chr(13) + chr(10) + chr(10) |
|||
next botellas |
|||
HQ9plus1 = HQ9plus1 + "No more bottles of beer on the wall, no more bottles of beer." + chr(13) + chr(10) + "Go to the store and buy some more, 99 bottles of beer on the wall." |
|||
case op = "+" |
|||
acumulador = (acumulador + 1) |
|||
case op = "E" |
|||
end |
|||
end case |
|||
if mid(codigo, cont, 1) <> "+" then |
|||
HQ9plus1 = HQ9plus1 + chr(13) + chr(10) |
|||
end if |
|||
next cont |
|||
HQ9plus = left(HQ9plus1, (length(HQ9plus1) - 2)) |
|||
end function |
|||
cls |
|||
do |
|||
input codigo |
|||
print HQ9plus(codigo): print |
|||
until false |
|||
end |
|||
</lang> |
|||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |