05-20-2025, 11:34 PM
(05-20-2025, 11:21 PM)PhilOfPerth Wrote: I have never created a Function, but always used Sub for repeated operations. I'm trying to find how to create and apply Functions, and what, if any, are their advantages (in my SIMPLE programmes) over Subs. I've created these few lines to experiment, but get no results from the Function.Your using function wrong.
Code: (Select All)Common Shared x, x$
x = 5: x$ = "ABC"
Print "Checkfunction returns";
Print CheckFunction$(x, x$)
CheckSub
Print "CheckSub returns"; x, x$
Function CheckFunction$ (x, x$)
x = x * 3: x$ = x$ + "DEF"
End Function
Sub CheckSub
x$ = x$ + x$
x = x + x
End Sub
What am I doing wrong?

x = 3
print Cubed(x)
end
function Cubed(X)
Cubed = X * X * X
end function