"Günther Schmidt" <
[hidden email]> wrote in message
news:
[hidden email]...
> Christoph,
>
> thanks for the help, I'm sorry I seem not to have brought my point across.
>
> What I need is a method to convert the string '#[1 22 44]' into a
> ByteArray.
>
> I'm not sure what your method does.
Perhaps I did not explain my examples well enough. What I posted was three
workspace code examples of different ways to accomplish what you describe,
not a method. It sounds like what you are interested in is the third one.
I have simplified it bellow:
=============
"Simple re-parse of the ByteArray printString"
string := '#[1 22 44]'.
baStrm := ByteArray writeStream.
((string copyFrom: 3 to: string size -1) subStrings: $ ) do: [ :each |
baStrm nextPut: each asNumber].
newBa := baStrm contents.
=============
The variable string would be the string representation of your ByteArray,
and newBa would be the ByteArray object created by parsing the string. If
you run the code you should see that it will do what you want. I am not
sure how this is ultimately being used in your program, but you may want to
provide some error checking/validation incase the user makes a typo.
The other code snippets in my previous post showed how you could use
Dolphin's existing ByteArray<<from*String: methods if you wanted to use Hex
or Base64 encoding.
Chris