A B++ programozási nyelv

Példakód


Végül egy példakód a nyelv dokumentációjából:
        class AppMain
        <definitions>
            
            method calculate
            3;;
            Number1;;
            Number2;;
            Operator;;
            end method
            
            <methods>
                
                method void run
                console << show ["Calculator"];;
                console << clear;;
                anchor RestartIt;;
                > this.showMenu;;
                console << ["Would you like to quit the program? (y/n) "];;
                declare userEntered [""];;
                console >> userEntered;;
                if [:this.userEntered] |=| ["y"]
                leave;;
                clean userEntered;;
                step RestartIt;;
                end method
                
                method void showMenu
                declare numberOne [0];;
                declare numberTwo [0];;
                declare operator [0];;
                console << ["%0DPlease enter the 1st number: %09"];;
                console >> numberOne;;
                console << ["%0DPlease enter the 2nd number: %09"];;
                console >> numberTwo;;
                console << ["%0DEnter the operator (+,-,*,/):%09%09"];;
                console >> operator;;
                console << ["%0DThe result is: " & ::
                :this.numberOne & ::
                :this.operator & ::
                :this.numberTwo & ::
                "=" & ::
                {this.calculate [:this.numberOne] ::
                [:this.numberTwo] [:this.operator]} ::
                &  "%0D"];;
                clean numberOne;;
                clean numberTwo;;
                clean operator;;
                end method
                
                method function calculate
                if [#Operator] | = | ["+"]
                return [#Number1 + #Number2];;
                if [#Operator] | = | ["-"]
                return [#Number1 - #Number2];;
                if [#Operator] | = | ["*"]
                return [#Number1 * #Number2];;
                if [#Operator] | = | ["/"]
                return [#Number1 / #Number2];;
                end method
                end class