Reinterning literals in deployed applications

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Reinterning literals in deployed applications

Günther Schmidt
Hi,

my *deployed* application needs to re intern a literal ByteArray entered
into a textbox.

I thought about using some sort of workspace window.

But then it occurred to me, that the necessary code to "evaluate" the
string entered will probably not be available in the deployed image, as
that part will most likely be stripped.

What would be a possible solution to this?

Günther


Reply | Threaded
Open this post in threaded view
|

Re: Reinterning literals in deployed applications

Christopher J. Demers
"Günther Schmidt" <[hidden email]> wrote in message
news:[hidden email]...

> Hi,
>
> my *deployed* application needs to re intern a literal ByteArray entered
> into a textbox.
>
> I thought about using some sort of workspace window.
>
> But then it occurred to me, that the necessary code to "evaluate" the
> string entered will probably not be available in the deployed image, as
> that part will most likely be stripped.
>
> What would be a possible solution to this?

Actually we _can_ include the compiler with a deployed Dolphin EXE (though a
workspace as part of the IDE might not be redistributable), so that could be
an option.  However in this case I think that might be too heavy handed.
Depending upon how free you are to dictate the format of the ByteArray you
may consider using either Hex of Base64 encoding as they have *fromString:
methods.  For example:

=================
ba := 'This is my byte array.' asByteArray.

"Base 64"
strm := String writeStream.
ba printBase64On: strm.
newBa := ByteArray fromBase64String: strm contents.
ba = newBa.

"Hex"
strm := String writeStream.
ba printHexOn: strm .
newBa := ByteArray fromHexString: strm contents.
ba = newBa.

"Simple re-parse of the ByteArray printString"
string := ba printString.
baStrm := ByteArray writeStream.
((string copyFrom: 3 to: string size -1) subStrings: $ ) do: [ :each |
baStrm nextPut: each asNumber].
newBa := baStrm contents.
ba = newBa.
=================

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Reinterning literals in deployed applications

Günther Schmidt
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.

Günther


Reply | Threaded
Open this post in threaded view
|

Re: Reinterning literals in deployed applications

Christopher J. Demers
"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