05-21-2025, 12:25 AM
(05-20-2025, 11:34 PM)ahenry3068 Wrote:(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
Ah, got it (well, some of it).I'll "fiddle" and see what I can do with multiple arguments Should be able to work this out now. Thanks both.
(Still don't see why I need Function though, I can do this and lots of other things with Sub and it seems simpler to use).
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) 
Please visit my Website at: http://oldendayskids.blogspot.com/

Please visit my Website at: http://oldendayskids.blogspot.com/