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 
Return to the default flat view Create a new topic Submit Reply
Re: who ate my byte? [message #54972 is a reply to message #54967] Mon, 23 July 2007 01:23 Go to previous messageGo 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
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
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: Fri Oct 10 13:59:17 PDT 2025

Total time taken to generate the page: 7.83911 seconds