Page 1 of 1
Why doesn't this work ?
Posted: 06 April 2011, 13:45 PM
by FFMan
Code: Select all
strText=MakeString(MemAddress(SDIn),inPtnr-1)
debug.print strText
SerialRead=strtext
'Doesn't work
'SerialRead=MakeString(MemAddress(SDIn),inPtnr-1)
the top bit of code works, (its setting the return value of a function) but naturally uses more storage.
The final line compiles but doesn't return any characters.
Maybe there is a better way - i expect there is, there usually is with my code !
Re: Why doesn't this work ?
Posted: 06 April 2011, 14:57 PM
by dkinzer
FFMan wrote:The final line compiles but doesn't return any characters.
I can't reproduce the problem here on either a native mode or a VM device using v3.3.0 of the compiler and v3.3.0 of the ZBasic Library. Here is the test case I used:
Code: Select all
Dim s as String
Sub Main()
Dim data(1 to 40) as Byte
Dim i as Integer
For i = 1 to 10
data(i) = CByte(i) + Asc("@")
Next i
Debug.Print "["; foo(data, 10); "]"
s = foo(data, 10)
Debug.Print "["; s; "]"
End Sub
Function foo(ByRef byteArray() as Byte, ByVal cnt as Byte) as String
foo = MakeString(byteArray.DataAddress, cnt)
End Function
This should produce the output
Code: Select all
[ABCDEFGHIJ]
[ABCDEFGHIJ]
If that's not what you see, let me know which version of the compiler you're using and which ZBasic Library version (if you're using a native mode device). If this works properly, perhaps you can modify it to create a test case that exhibits the problem you're seeing.
Posted: 07 April 2011, 3:35 AM
by FFMan
ok - so it should work
i'll take a longer look over the weekend, and assuming i don't spot some muppetry in my code, i'll run your test code.
i'll let you know what i find.
thanks