Indeed, it's most likely a bug. Here's some standalone test code:
dll-test.bas (the dll to test):
Code: Select all
function _
text alias "text"( _
byref foo as string ) _
as string export
return( "bar:" + foo )
end function
And the test code that shows the problem in question:
Code: Select all
#inclib "dll-test"
declare function _
text alias "text"( _
byref as string ) _
as string
for _
i as integer => 0 _
to 270
? text( str( i ) )
next
sleep()
@chung: you can wrap the string in a type by way of a workaround:
workaround.bi
Code: Select all
type _
Workaround
public:
declare constructor()
declare constructor( _
byref as string )
declare constructor( _
byref as Workaround )
declare destructor()
declare operator _
let( byref as Workaround )
declare operator _
let( byref as string )
declare operator _
cast() as string
private:
as string _
_string
end type
constructor _
Workaround()
end constructor
constructor _
Workaround( _
byref value as string )
_string => value
end constructor
constructor _
Workaround( _
byref rhs as Workaround )
_string => rhs._string
end constructor
destructor _
Workaround()
end destructor
operator _
Workaround.let( _
byref rhs as Workaround )
_string => rhs._string
end operator
operator _
Workaround.let( _
byref rhs as string )
_string => rhs
end operator
operator _
Workaround.cast() _
as string
return( _string )
end operator
And then return it instead of the string:
dll-test.bas
Code: Select all
#include once "workaround.bi"
function _
text alias "text"( _
byref foo as string ) _
as string export
return( "bar:" + foo )
end function
function _
text2 alias "text2"( _
byref foo as string ) _
as Workaround export
return( Workaround( "bar:" + foo ) )
end function
This yields the expected results:
Code: Select all
#inclib "dll-test"
#include once "workaround.bi"
declare function _
text2 alias "text2"( _
byref as string ) _
as Workaround
for _
i as integer => 0 _
to 270
? text2( str( i ) )
next
sleep()
@the devs: this seems to be a crippling bug, indeed. Has this been reported somewhere? Is there something that we're missing here?