The code
DEF TEST A$ OUT A$ A$=A$+"1" ENDwill generate an "Uninitialized variable used" error when TEST is used.
Root / SmileBASIC Bug Reports / [.]
DEF TEST A$ OUT A$ A$=A$+"1" ENDwill generate an "Uninitialized variable used" error when TEST is used.
DEF TEST$(A$) RETURN A$+"1" ENDHowever, the advantage of using OUT is that you can have multiple return values. Which if it were handled as you said, you could do something like:
DEF TEST A$,B$ OUT A$,B$ A$=A$+"1" B$=B$+"2" END
while this does sound bad (should be fixed IMO), it can be easily worked around:I like this solution. Thank you! Calling it like so.DEF TEST INA$,INB$ OUT A$,B$ .. END
TEST A$ B$ OUT A$ B$Previously I accomplished this by passing in an array as a parameter (it's address) and altering the element values. This modifies the original contents without having to use OUT.
DEF MY_TEST ARR ARR[0]=7 ARR[1]=8 ARR[2]=9 END VAR X[3] X[0]=1 X[1]=2 X[2]=3 ? X[0];",";X[1];",";X[2] MY_TEST X ? X[0];",";X[1];",";X[2]
That's very interesting. I did not know that you can pass arrays as args.while this does sound bad (should be fixed IMO), it can be easily worked around:I like this solution. Thank you! Calling it like so.DEF TEST INA$,INB$ OUT A$,B$ .. ENDTEST A$ B$ OUT A$ B$Previously I accomplished this by passing in an array as a parameter (it's address) and altering the element values. This modifies the original contents without having to use OUT.DEF MY_TEST ARR ARR[0]=7 ARR[1]=8 ARR[2]=9 END VAR X[3] X[0]=1 X[1]=2 X[2]=3 ? X[0];",";X[1];",";X[2] MY_TEST X ? X[0];",";X[1];",";X[2]