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

Home » Public Forums » archive » Re: who ate my byte?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: who ate my byte? [message #54961] Mon, 23 July 2007 10:39
rtowler is currently offline  rtowler
Messages: 28
Registered: June 2006
Junior Member
On Jul 23, 2:06 pm, kBob <KRD...@gmail.com> wrote:

Thanks for the replies... I figured it was something like this.
Paolo, you've helped explain some 'weird' behavior I was seeing. I'm
receiving packets with fields terminated by null bytes and I know now
I need to be careful how I parse the string data.

>> N 60 29.76
>> W 178 42.48
>
> What are you doing in the middle of the Bering Sea? I thought David
> Fanning was our one and only IDL Globe Trekker.

David may not be the only globe trekker, but he gets to go to much
nicer places than I :)

N 61 46.00
W 179 56.22

-r
Re: who ate my byte? [message #54967 is a reply to message #54961] Mon, 23 July 2007 07:06 Go to previous message
KRDean is currently offline  KRDean
Messages: 69
Registered: July 2006
Member
> N 60 29.76
> W 178 42.48

What are you doing in the middle of the Bering Sea? I thought David
Fanning was our one and only IDL Globe Trekker.

Kelly Dean
Fort Collins, CO
Re: who ate my byte? [message #54972 is a reply to message #54967] Mon, 23 July 2007 01:23 Go to previous message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
rtowler@gmail.com wrote:
> IDL> print,strlen('test' + string(0B))
> 4
> IDL> print,strlen('test' + string(1B))
> 5
>
> Huh?
>
> I need to zero terminate data packets I'm sending (sent as byte array
> via UDP) but IDL silently strips them. Obviously I can do something
> like:
>
> data = [BYTE('test'), 0B]
>
> but I am curious as to why IDL does this. Any ideas?



Hidden deep within the docs, in the "bulding IDL applications" book,
one can find this explanation:

Due to the way in which strings are implemented in IDL, applying the STRING
function to a byte array containing a null (zero) value will result in the
resulting string being truncated at that position. Thus, the statement,

PRINT, STRING([65B, 66B, 0B, 67B])
produces the following output:

AB

So at least it is documented somewhere...

Ciao,
Paolo





>
> -Rick
>
> N 60 29.76
> W 178 42.48
>
Re: who ate my byte? [message #54974 is a reply to message #54972] Mon, 23 July 2007 01:09 Go to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Jul 22, 7:02 pm, rtow...@gmail.com wrote:
> IDL> print,strlen('test' + string(0B))
> 4
> IDL> print,strlen('test' + string(1B))
> 5
>
> Huh?
>
> I am curious as to why IDL does this. Any ideas?

It probably is the C library underneath that does this, with its 0
terminated strings.

Maarten
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Linux Seg fault (was Re: segmentation fault, TVRD, writing image)
Next Topic: Selecting the Location of Contour Labels

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

Current Time: Wed Oct 08 19:56:35 PDT 2025

Total time taken to generate the page: 0.00471 seconds