Why doesn't this work ?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Why doesn't this work ?

Post 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 !
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Why doesn't this work ?

Post 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.
- Don Kinzer
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post 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
Post Reply