Hello Forum,
Could someone please explain why this program prints "Bacon, Bacon" instead of "Bacon, Tomato"?
'---Load Console Module
Uses "Console"
Dim s(2) as String
Dim sResult as String
function sTest( ByRef s1 as String, ByRef s2 As String) As String
Function = s1 + ", " + s2
End Function
s(1) = "Bacon"
s(2) = "Tomato"
sResult = sTest( s(1), s(2))
printl sResult
WaitKey
If string array elements are not passed to the function, then the correct output "Bacon, Tomato" is produced.
'---Load Console Module
Uses "Console"
Dim t1 As String
Dim t2 as String
Dim sResult as String
function sTest( ByRef s1 as String, ByRef s2 As String) As String
Function = s1 + ", " + s2
End Function
t1 = "Bacon"
t2 = "Tomato"
sResult = sTest( t1, t2 )
printl sResult
'---Wait for a key press
WaitKey
Bookmarks