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

Home » Public Forums » archive » Bug with string methods?
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
Bug with string methods? [message #89846] Wed, 10 December 2014 14:31 Go to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
Am I misunderstanding the documentation, or is there a bug with some string methods?

When a string has more than one character, substring() works as I expected, from the documentation:

IDL> str='ab'
IDL> print,str.substring(-1)
b

But if the string has length 1, I get an empty string:

IDL> str='a'
IDL> print,str.substring(-1)

IDL> print,strlen(str.substring(-1))
0
IDL>

A similar problem happens with remove():

IDL> str='ab'
IDL> print,str.remove(-1)
a
IDL> str='a'
IDL> print,str.remove(-1)
a
Re: Bug with string methods? [message #89850 is a reply to message #89846] Wed, 10 December 2014 16:02 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, December 10, 2014 3:31:21 PM UTC-7, Paulo Penteado wrote:
> Am I misunderstanding the documentation, or is there a bug with some string methods?
>
> When a string has more than one character, substring() works as I expected, from the documentation:
>
> IDL> str='ab'
> IDL> print,str.substring(-1)
> b
>
> But if the string has length 1, I get an empty string:
>
> IDL> str='a'
> IDL> print,str.substring(-1)
>
> IDL> print,strlen(str.substring(-1))
> 0
> IDL>
>
> A similar problem happens with remove():
>
> IDL> str='ab'
> IDL> print,str.remove(-1)
> a
> IDL> str='a'
> IDL> print,str.remove(-1)
> a

Drats, that looks like a bug. Good catch Paulo. I'll try to slip it into the next patch release.
-Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Request from the Far Beyond
Next Topic: EOF analysis of large data with NAN's

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

Current Time: Wed Oct 08 09:13:43 PDT 2025

Total time taken to generate the page: 0.00401 seconds