' Function Return — FUNCTION with return values
#COMPILE EXE
#DIM ALL

FUNCTION Add(a AS LONG, b AS LONG) AS LONG
    FUNCTION = a + b
END FUNCTION

FUNCTION Multiply(a AS LONG, b AS LONG) AS LONG
    FUNCTION = a * b
END FUNCTION

FUNCTION MaxOf(x AS LONG, y AS LONG) AS LONG
    IF x > y THEN
        FUNCTION = x
    ELSE
        FUNCTION = y
    END IF
END FUNCTION

FUNCTION IsEven(n AS LONG) AS LONG
    IF n MOD 2 = 0 THEN
        FUNCTION = 1
    ELSE
        FUNCTION = 0
    END IF
END FUNCTION

FUNCTION PBMAIN() AS LONG
    LOCAL a AS LONG
    LOCAL b AS LONG
    LOCAL result AS LONG

    a = 15
    b = 7

    result = Add(a, b)
    PRINT STR$(a) & " + " & STR$(b) & " = " & STR$(result)

    result = Multiply(a, b)
    PRINT STR$(a) & " * " & STR$(b) & " = " & STR$(result)

    result = MaxOf(a, b)
    PRINT "MaxOf(" & STR$(a) & ", " & STR$(b) & ") = " & STR$(result)

    IF IsEven(result) THEN
        PRINT STR$(result) & " is even"
    ELSE
        PRINT STR$(result) & " is odd"
    END IF

    FUNCTION = 0
END FUNCTION
