The behavior of this type of assignment seems even more (last test) degraded for the 'Byref' return case:
Code: Select all
Function test1(Byref s As String) Byref As String
s = "1"
Return s
End Function
Print "Byref As String:"
Print
Dim As String s1
test1(s1)
Print "'" & s1 & "'"
(test1(s1)) = "12"
Print "'" & s1 & "'"
Print
Dim As String * 2 s2
test1(s2)
Print "'" & s2 & "'"
(test1(s2)) = "12"
Print "'" & s2 & "'"
Print
Function test2(Byref s As Zstring) Byref As Zstring
s = "1"
Return s
End Function
Print "Byref As Zstring:"
Print
Dim As Zstring * 3 s3
test2(s3)
Print "'" & s3 & "'"
(test2(s3)) = "12"
Print "'" & s3 & "'"
Print
Dim As String * 2 s4
test2(s4)
Print "'" & s4 & "'"
(test2(s4)) = "12"
Print "'" & s4 & "'"
Print
Sleep
With new fbc version 1.20.0:Byref As String:
'1'
'12'
'1'
'1'
Byref As Zstring:
'1'
'12'
'1'
'12'
Can this behavior be improved ?Byref As String:
'1'
'12'
'1 '
'1 '
Byref As Zstring:
'1'
'12'
'1 '
'1 '