Hehe,
since PB/DOS I have the ASCII table in my head, so I am quite sure the result will be "thinBASIC !"
UNIONs are cool feature when porting from other languages, but in practice I use more the DIM .. AT syntax to achieve same result in most projects.
I think in this special case it is enough to have the array dimensioned to 11 elements and the string to 11 characters.
Why?
Because STRING * n is not null terminated, which is the difference compared to ASCIIZ * n.
So the code could be in theory this (added one method for array fill):
Union MyUnion
b(11) As Byte
st As String * 11
End Union
Dim MyU As MyUnion
'---Method 1 to fill UDT array
With MyU
.b( 1) = 116
.b( 2) = 104
.b( 3) = 105
.b( 4) = 110
.b( 5) = 66
.b( 6) = 97
.b( 7) = 115
.b( 8) = 105
.b( 9) = 99
.b(10) = 32
.b(11) = 33
End With
'---Method 2 to fill UDT array
With MyU
.b( 1) = 116, 104, 105, 110, 66, 97, 115, 105, 99, 32, 33
End With
'---Method 3 to fill UDT array
MyU.b( 1) = 116, 104, 105, 110, 66, 97, 115, 105, 99, 32, 33
MsgBox 0, MyU.st
Petr
Bookmarks