' MIN/MAX functions
#COMPILE EXE
#DIM ALL

FUNCTION Min(BYVAL a AS LONG, BYVAL b AS LONG) AS LONG
    IF a < b THEN FUNCTION = a ELSE FUNCTION = b
END FUNCTION

FUNCTION Max(BYVAL a AS LONG, BYVAL b AS LONG) AS LONG
    IF a > b THEN FUNCTION = a ELSE FUNCTION = b
END FUNCTION

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

    PRINT "MIN/MAX Demo"
    FOR i = 0 TO 9
        a = i * 7
        b = i * 5 + 20
        PRINT "min(" + STR$(a) + "," + STR$(b) + ")=" + STR$(Min(a, b)) + "  max=" + STR$(Max(a, b))
    NEXT i
    PRINT "Done."
    FUNCTION = 0
END FUNCTION
