comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: converting bytarr into strarr
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: converting bytarr into strarr [message #44513 is a reply to message #44511] Tue, 21 June 2005 14:59 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
It's weird that the string function doesn't offer a keyword for this.
But how about first converting to integer?

b=string(fix(a))

Benjamin


Paul Van Delst wrote:
> Hello there,
>
> This is probably a simple question, but I haven't found out how to do it.
>
> How does one convert a byte array into a equivalent sized string array?
> E.g. consider the following:
>
> IDL> a=bindgen(20,40)
> IDL> help, a
> A BYTE = Array[20, 40]
> IDL> b=string(a)
> IDL> help, b
> B STRING = Array[40]
> IDL>
>
> or
>
> IDL> a=bindgen(2,4,5,6)
> IDL> help, a
> A BYTE = Array[2, 4, 5, 6]
> IDL> b=string(a)
> IDL> help, b
> B STRING = Array[4, 5, 6]
>
>
> What I want to do is convert "a" into a string array, "b", that has the
> same dimensions as the original byte array, [20, 40], or [2, 4, 5, 6]
> i.e. each element of "b" is a single character corresponding to the byte
> value in "a".
>
> Everything I've read in the IDL help tells me that a byte array will
> always "lose" the first dimension as the bytes are converted into
> concatenated strings.
>
> Is there a simple way around this? (I could loop over the dimensions of
> "a" I guess).
>
> thanks,
>
> paulv
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: converting bytarr into strarr
Next Topic: Re: Swap even/odd elements in array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 17:22:49 PDT 2025

Total time taken to generate the page: 0.63968 seconds