Task

Implement a    HQ9+    interpreter or compiler.




'Try this hq9+ program - "hq9+HqQ+Qq"
Prompt "Please input your hq9+ program."; code$
Print hq9plus$(code$)
End
 
Function hq9plus$(code$)
    For i = 1 to Len(code$)
        Select Case
            Case Upper$(Mid$(code$, i, 1)) = "H"
                hq9plus$ = hq9plus$ + "Hello, world!"
            Case Upper$(Mid$(code$, i, 1)) = "Q"
                hq9plus$ = hq9plus$ + code$
            Case Mid$(code$, i, 1) = "9"
                For bottles = 99 To 1 Step -1
                     hq9plus$ = hq9plus$ + str$(bottles) + " bottle"
                     If (bottles > 1) Then hq9plus$ = hq9plus$ + "s"
                     hq9plus$ = hq9plus$ + " of beer on the wall, " + str$(bottles) + " bottle"
                     If (bottles > 1) Then hq9plus$ = hq9plus$ + "s"
                     hq9plus$ = hq9plus$ + " of beer,"  + chr$(13) + chr$(10) + "Take one down, pass it around, " + str$(bottles - 1) + " bottle"
                     If (bottles > 2) Or (bottles = 1) Then hq9plus$ = hq9plus$ + "s"
                     hq9plus$ = hq9plus$ + " of beer on the wall." + chr$(13) + chr$(10)
                Next bottles
                hq9plus$ = hq9plus$ + "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 Mid$(code$, i, 1) = "+"
                accumulator = (accumulator + 1)
        End Select
        If Mid$(code$, i, 1) <> "+" Then
            hq9plus$ = hq9plus$ + chr$(13) + chr$(10)
        End If
    Next i
    hq9plus$ = Left$(hq9plus$, (Len(hq9plus$) - 2))
End Function