Passing a '(Z|W)string * N' array to a procedure is allowed.
But the procedure code does not work because the (Z|W)string size is not passed, and a size of 1 character is taken instead by default.
- Bug example:
Sub test(z() As Zstring * 10)
For i As Integer = Lbound(z) To Ubound(z)
Print z(i)
Next I
End Sub
Dim As Zstring * 10 z(...) = {"one", "two", "three"}
test(z())
Sleep
one
ne
e
- If everything worked fine, the compiler should also pass the zstring size to the procedure and do internally what I added in a macro:
Sub test(z() As Zstring * 10, Byval size As Integer)
#define _z(n) *(@z(Ubound(z)) - Ubound(z) + (n) * size)
For i As Integer = Lbound(z) To Ubound(z)
' Print z(i)
Print _z(i)
Next I
End Sub
Dim As Zstring * 10 z(...) = {"one", "two", "three"}
test(z(), Sizeof(z(Lbound(z))))
print
Sleep
one
two
three
- A workaround might be to pass an array of zstring pointers:
- Another workaround might be to define your zstring into a Type and then pass an array of Type elements: