I wouldn't like that trade off losing the ability to use %,$, etc. on variables, either. That stated, if there was a way to make FUNCTION sm(x$) AS STRING, as per your example, that would be cool.
To me, I'm not seeing a good "One size fits all." method here.
Several methods could be made, the best one would depend on best meeting the needs of the program. While function is a neat compact way to PRINT the results when working explicitly with numeric literals, it's not so hot when we need to work with variables.
Or... we just DIM STRING and call each string math sub like sm_mult a, b, c... sm_div a, b, c... etc.
Or with a DIM STRING and function... PRINT sm_mult$ (a, b) or c = sm_mult$ (a, b) to place the results in a variable, like a sub would.
Anyone have any particular preferences or other sub/function call variants?
Pete
PS Thanks for the link. I actually had to make a spelling edit on that page before coming back.
To me, I'm not seeing a good "One size fits all." method here.
Several methods could be made, the best one would depend on best meeting the needs of the program. While function is a neat compact way to PRINT the results when working explicitly with numeric literals, it's not so hot when we need to work with variables.
Code: (Select All)
DEFSTR A-C
a = "24"
b = "4"
sm a, "*", b: PRINT c
SUB sm (a, c, b)
PRINT a, c, b
SELECT CASE c
CASE "*"
CASE "/"
CASE "+"
CASE "-"
END SELECT
c = runningtotal$
END SUB
Or... we just DIM STRING and call each string math sub like sm_mult a, b, c... sm_div a, b, c... etc.
Or with a DIM STRING and function... PRINT sm_mult$ (a, b) or c = sm_mult$ (a, b) to place the results in a variable, like a sub would.
Anyone have any particular preferences or other sub/function call variants?
Pete
PS Thanks for the link. I actually had to make a spelling edit on that page before coming back.