Give a function a useful name
THE BASIC LANGUAGE
A FUNCTION calculates an answer. A SUB is a named job you can call for its effect, such as writing a line to the output.
FUNCTION Fare(count AS Integer, rate AS Integer = 2)
RETURN count * rate
END FUNCTIONSUB Announce(total AS Integer)
PRINT "Fare: " & total
END SUBFUNCTION Run()
DIM total = Fare(3)
Announce(total)
RETURN total
END FUNCTIONFare receives a count and a rate. The default rate is 2. Fare(3) returns 6, while Fare(3, 4) returns 12. Announce prints the value it receives. Run returns the number to its own caller.
Use RETURN value for a function result. EXIT SUB and EXIT FUNCTION leave without a result. PCA3D BASIC supports optional default parameters. Pass explicit values or return updated data when adapting a classic routine that uses BYREF.
