In the past when I have had to convert old QB code, my approach has always been to isolate the GOSUB calls and pull the code out in to a function.
BYREF makes the most sense to me if there are multiple variables and they need to change as a result of the call.
Just for fun, a not very efficient use of some (probably) little known syntax utilizing the LET keyword:
Code: Select all
type Double3Tuple
as double signval
as double absolute
as double squared
end type
function Numericate( byval n as double ) as Double3Tuple
return type( sgn(n), abs(n), n * n )
end function
dim as double a, b, c, n
n = -45.6
let( a, b, c ) = Numericate( n )
print "n = " & n
print "a = " & a
print "b = " & b
print "c = " & c
sleep
It can be considered inefficient because the data is passed and returned by value resulting in extra copies of the data in temporary memory locations.